jsTree Open a branch

后端 未结 8 746
长发绾君心
长发绾君心 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);
        }
    }
    
    0 讨论(0)
  • 2021-02-02 12:06

    just use this if you use json

    $("#treeId").on
    ('loaded.jstree', function() {
     $("#treeId").jstree("open_node", $("#nodeId"));
     });
    
    0 讨论(0)
提交回复
热议问题