我构建了一个看起来像这样的Json:
[{“data”:{“title”:“A部分”,“attr”:{“id”:“II”,“title”:“Products”}},“state”:“closed”, “children”:[{“data”:{“title”:“Part AA”,“attr”:{“id”:“12”,“title”:“Chapter22”}},“state”:“closed” ,“children”:[{“data”:{“title”:“Chapter B”,“attr”:{“id”:“25”,“title”:“Apples - ”}},“state”:“ 已选择“,”儿童“:[{”data“:{”title“:”Oranges“,”attr“:{”id“:”28“,”title“:”Red“} },“metadata”:{“id”:“132”,“description”:“MyApples”,“fullClassification”:“Des”}}],“metadata”:{“id”:“155”,“description” :“Toys - ”,“fullClassification”:“Des2”}}],“metadata”:{“id”:“12333”,“description”:“Des5”,“fullClassification”:“0800000000”}}],“元数据“:{”id“:”243“,”description“:”Des34“,”fullClassification“:”Des324“}}]
我将这个Json转移到Jstree :(这是ui插件,用于处理选择)
$("#jstree01").jstree({
"plugins": ["themes", "ui"],
"themes": {
"theme": "default-rtl",
"dots": false,
"icons": false
},
"ui": {
"select_limit": 1,
"selected_parent_close": false,
"select_prev_on_delete": false,
},
结果:我有一棵有效的树,但没有选择任何节点。 如何通过传输到Jstree的Json选择节点?
答案 0 :(得分:0)
http://www.jstree.com/docs/json/
您好, 你必须以这种方式设置state参数:
state: {
opened : boolean // is the node open
disabled : boolean // is the node disabled
selected : boolean // is the node selected
},