Simon
Simon

Reputation: 1463

extjs treepanel: expand() & expandChildNodes()

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.

Upvotes: 5

Views: 16234

Answers (3)

JustBeingHelpful
JustBeingHelpful

Reputation: 18980

Another way to get to the descendants is to use node.expand(true), where node is the root node. Similarly, you can take any node within the tree and expand all of its descendant nodes using this same code. A common usage is for the selected node.

Upvotes: 0

aswininayak
aswininayak

Reputation: 973

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

Upvotes: 1

dbrin
dbrin

Reputation: 15673

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

Upvotes: 2

Related Questions