I am using the JQuery plugin jsTree, http://www.jstree.com/ I am able to expand the whole tree with the following method:
$(\"#tree\").jstree(\"open_all\");
Here is function that can open a specific node and all its parents.
function expandNode(nodeID) {
// Expand all nodes up to the root (the id of the root returns as '#')
while (nodeID != '#') {
// Open this node
$("#jstree").jstree("open_node", nodeID)
// Get the jstree object for this node
var thisNode = $("#jstree").jstree("get_node", nodeID);
// Get the id of the parent of this node
nodeID = $("#jstree").jstree("get_parent", thisNode);
}
}
just use this if you use json
$("#treeId").on
('loaded.jstree', function() {
$("#treeId").jstree("open_node", $("#nodeId"));
});