jstree复选框自定义显示隐藏和初始化默认选中css
首先须要配置 Checkbox pluginnode
"plugins" : ['checkbox']
state: {checked: true}
示例:json
$('#demo_tree').jstree({ "core" : { 'data': [ { "id" : "ajson1", "parent" : "#", "text" : "Simple root node", state: {checked: true}}, { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" }, { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" }, { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }, ] }, "plugins" : ['checkbox'], });
jstree 自己不支持在节点中隐藏 checkbox,国外有个大佬给出一个利用 css 来隐藏的解决方案:数据结构
首先来一段 csside
.no_checkbox>i.jstree-checkbox{display:none}
而后在 data 的 json 数据结构中spa
$('#demo_tree').jstree({ "core" : { 'data': [ { "id" : "ajson1", "parent" : "#", "text" : "Simple root node", state: {checked: true}}, { "id" : "ajson2", "parent" : "#", "text" : "Root node 2" }, { "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1" , a_attr: {class: "no_checkbox"}}, { "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2" }, ] }, "plugins" : ['checkbox'], });
效果:code
jstree version => 3.3.8blog
参考:get
https://stackoverflow.com/questions/6112567/jstree-hide-checkboxio