Reputation: 71
I am using jsTree to display a tree. I want to select all the nodes in the tree of which I can use $("#my-tree").jstree("check_all")
. This works fine.
However, this will expand all the nodes and having a big tree will push the rest of the content all the way down.
I want to collapse the tree after checking all the nodes but using $("#my-tree").jstree("close_all")
after checking all nodes doesn't work.
Anyone has a solution to this?
$("#my-tree").jstree({
"checkbox": {
"keep_selected_style": false
},
"plugins": ["checkbox"]});
$("#my-tree").jstree("hide_dots");
$("#my-tree").jstree("check_all");
$("#my-tree").jstree("close_all");
Upvotes: 2
Views: 1339
Reputation: 21
You can use ready.jstree event Should use something like this:
var jstreeid = $('#jstree_counties');
jstreeid.jstree({'plugins':["wholerow","checkbox"], 'core' : {
'data' : {
"url" : "json url",
"dataType" : "json"
}
}
}).on('ready.jstree', function () {
jstreeid.jstree("close_all");
});
Upvotes: 1