我正在使用jstree jquery插件来显示和管理树。这是json数据:
0: {id:35, name:amrs trade, parent_id:null}
1: {id:36, name:trips, parent_id:35}
2: {id:37, name:tribute, parent_id:null}
3: {id:38, name:music, parent_id:null}
4: {id:39, name:recordings, parent_id:38}
5: {id:40, name:live shows, parent_id:38}
6: {id:41, name:others, parent_id:null}
7: {id:42, name:investments, parent_id:null}
8: {id:43, name:gold & silver, parent_id:42}
9: {id:44, name:debentures, parent_id:42}
10: {id:46, name:production, parent_id:35}
11: {id:54, name:real estate, parent_id:42}
我正在创建渲染我的树:
$("#incomeCategoryTree").jstree({
"json_data" : {
"data" : income,
"progressive_render" : true
},
"plugins" : [ "themes", "json_data" ]
})
我想显示树并让它最初打开一些选定的节点(现在,只显示顶层,隐藏所有非顶级节点)。我可以在json上面添加什么选项来使jstree最初扩展所选节点?
答案 0 :(得分:0)
州:open
/ closed
完成工作:
0: {id:35, name:amrs trade, parent_id:null, state:open}
1: {id:36, name:trips, parent_id:35}
2: {id:37, name:tribute, parent_id:null}
3: {id:38, name:music, parent_id:null}
4: {id:39, name:recordings, parent_id:38}
5: {id:40, name:live shows, parent_id:38}
6: {id:41, name:others, parent_id:null}
7: {id:42, name:investments, parent_id:null, state:closed}
8: {id:43, name:gold & silver, parent_id:42}
9: {id:44, name:debentures, parent_id:42}
10: {id:46, name:production, parent_id:35}
11: {id:54, name:real estate, parent_id:42}