I am using the following code:
$("#treeview").jstree();
$("#treeview").jstree(\'open_all\');
With the following html:
You can also apply animation to the opening and closing like so:
$(document)
.on("click", "#open-all-folders", function () {
// param1 set to null to open/close all nodes
// param2 is the duration in milliseconds
$("#tree-ref").jstree().open_all(null, 200);
})
.on("click", "#close-all-folders", function () {
$("#tree-ref").jstree().close_all(null, 200);
});
(or similarly apply to .on('ready.jstree', function() { // code here }
);