根据问题,我有类似的要求,并尝试了上面的@chris 答案,但建议的答案没有成功。
这是我为使其正常工作所做的工作
.bind('check_node.jstree', function (e, data) { //check all parent nodes
//var currentNode = data.rslt.obj.attr("id");
var parentNode = data.rslt.obj.attr("parent_id")
$('#demo').jstree('check_node', '#'+parentNode);
})
.bind('uncheck_node.jstree', function (e, data) {//uncheck all child nodes
var allChildNodes = data.inst._get_children(data.rslt.obj);
allChildNodes.each(function(idx, listItem) {
$('#demo').jstree('uncheck_node', '#'+$(listItem).attr("id"));
});
})
.jstree({
// List of active plugins
"checkbox": {
real_checkboxes: true,
two_state: true,
checked_parent_open: true,
override_ui:true
},
"plugins" : [
"themes","json_data","ui","cookies","dnd","search","types","hotkeys","contextmenu","crrm", "checkbox"
]
})