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

  

posted @ 2018-06-11 14:04  Vincent_void  阅读(269)  评论(0编辑  收藏  举报