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