extjs treepanel: expand() & expandChildNodes()

15,460

Solution 1

ExtJS 4x has expandAll() method on the Tree Panel component. This will expand every node recursively.

Solution 2

if you want to expand to a partcular level then in that case:

           expandTo:function(level){

                    treePanel.collapseAll();
                    treePanel.getRootNode().cascadeBy(function (node) {

                          if (node.getDepth() < level) { node.expand(); }
                          if (node.getDepth() == level) { return false; }
                     });
         }
Share:
15,460
Simon
Author by

Simon

Updated on June 09, 2022

Comments

  • Simon
    Simon almost 2 years

    If I write:

    rootNode.expand()
    

    I can only get access to the children nodes of this rootNode, but can't get access to the grandchildren nodes of this rootNode. I have to write:

    rootNode.expandChildNodes()
    

    in order to acheive it.

    Is there another way to obtain the grandchildren or further children nodes even if the tree is collapsed? other than using node.eachChild() function? I tried:

    rootChildNode.firstChild
    

    but it doesn't work.