Search code examples
jqueryfancytree

Expand Tree to a specific level


How can I use node.setExpanded(true); to expand the tree only to a certain level?

What I mean is that I've got 6 depth-levels and only want 5 to be expanded -- the last one should be excluded.


Solution

  •     $("#treeView").fancytree("getRootNode").visit(function(node){
            if(node.getLevel() < 3) {
                node.setExpanded(true);
            }
        });