如何关闭未选中的节点?现在所有节点都打开。只能为选定的节点打开吗?
$(document).ready(function () {
$('#jstree').jstree({
"core": {
"themes": {
"variant": "large",
"icons": false,
},
"data": @Html.Raw(ViewBag.Json),
},
"checkbox": {
"keep_selected_style": false,
},
"plugins": ["wholerow", "checkbox", "sort"],
});
});
Image below is how its look. Negeri Sembilan & Pahang should be close coz non of it is selected
答案 0 :(得分:0)
尝试
$(document).ready(function () {
$('#jstree').jstree({
"core": {
"themes": {
"variant": "large",
"icons": false,
},
"data": @Html.Raw(ViewBag.Json),
},
"checkbox": {
"keep_selected_style": false,
"tie_selection": false
},
"plugins": ["wholerow", "checkbox", "sort"],
}).bind("check_node.jstree", function (e, data) {
closeNode();
});
});
function closeNode() {
$('#jstree li').each(function (index, value) {
var node = $("#jstree").jstree().get_node(this.id);
if (!node.state.checked && node.state.opened) {
$("#jstree").jstree('close_node', node);
}
});
}