jsTree Open a branch

后端 未结 8 745
长发绾君心
长发绾君心 2021-02-02 11:07

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\");
         


        
8条回答
  •  失恋的感觉
    2021-02-02 11:58

    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);
        }
    }
    

提交回复
热议问题