Collapse Or Expand A jsTree Node Programmatically
Good day all!
Here's a snippet to collapse or exand a jstree node programmatically on page load based on the node id. The code below will collapse if node id is '45' while other nodes remain open.
Here's a snippet to collapse or exand a jstree node programmatically on page load based on the node id. The code below will collapse if node id is '45' while other nodes remain open.
$('#TreeRoles').bind('ready.jstree', function (e, data) { var $tree = $(this); $($tree.jstree().get_json($tree, { flat: true })).each(function (index, value) { var node = $tree.jstree().get_node(this.id); if (node.id === "45") { $tree.jstree().close_node({ "id": node.id }); } else { $tree.jstree().open_node({ "id": node.id }); } }); });
Comments
Post a Comment