JSTree如何實現第二級菜單異步從數據庫讀取。

參考文檔:

https://www.cnblogs.com/luozhihao/p/4679050.html

http://jsfiddle.net/vakata/2kwkh2uL/5/ 

 

核心的關鍵點是:

組裝節點的children元素時,設置  children = true

 

 $('#jstree_company').jstree({
                "core": {
                    "animation": 0,
                    "check_callback": true,
                    "themes": { "stripes": true },
                    'data': {
                        'url': function (node) {
                            return '/IS/CDictionary/GetDictionTree';
                        },
                        'data': function (node) {
                            return { 'id': node.id,'type':'company' };
                        }
                    }
                },
                "plugins": ["contextmenu", "dnd"],
            });

 

 

組裝的後臺代碼:

 JSTree treeFlow = new JSTree()
                {
                    id = item.DictID.ToString(),
                    parent = id,
                    text = item.Title,
                    state = new NodeState() { opened = false },
                    children = true
                };
                trees.Add(treeFlow);

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章