easyui tree自定义属性用法

easyui为树显示提供了以下属性,

id:节点id,这个很重要到加载远程服务器数据 which is important to load remote data 
text: 显示的节点文本 
state: 节点状态, 'open' 或者 'closed', 默认是 'open'. 当设置为 'closed', 节点所有的子节点将从远程服务器站点加载 
checked: 指明检查节点是否选中. 

 

要想在树点击事件中获取这些属性以外的属性怎么办呢,如点击树节点的时候想获取一个跟这个节点关联的对象id又该怎么做呢,easyui tree json数据提供了自定义属性来解决这个问题。

attributes: 可以添加到节点的自定义属性 

attributes是一个对象,任何自定义属性都可以以json键值对的形式放里面 attributes: {'pkid':'ssddd','url':'a.html'}

[{
    "id":1,
    "text":"根类",
    "attributes":{"url":""},
    "children":[{
        "id":11,
        "text":"系统类",
        "attributes":{"url":""},
        "children":[{
            "id":110,
            "text":"操作类",
            "attributes":{"url":"manage/class/class.html"}
        },{
            "id":112,
            "text":"模块类",
            "attributes":{"url":"manage/class/class.html"}
        },{
            "id":113,
            "text":"人员类",
            "attributes":{"url":"manage/class/class.html"}
        }]
    }
}]

那该怎么取这些自定义属性值呢?参照下面

onClick:function(node)
            {
                var tabTitle =node.text;
                var id = node.id;
                var url=node.attributes.url;
                var icon = node.iconCls;
                if(url){
                    //addTab(id,tabTitle, url, icon);    
                }
            }

 

 

转载于:https://www.cnblogs.com/langhua/p/3700572.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值