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);    
                }
            }

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM