开发者

extjs treepanel: expand() & expandChildNodes()

开发者 https://www.devze.com 2023-02-24 16:53 出处:网络
If I write: rootNode.expand() I can only get access to the children nodes of this rootNode, but can\'t get access to the grandchildre开发者_开发百科n nodes of this rootNode. I have to write:

If I write:

rootNode.expand()

I can only get access to the children nodes of this rootNode, but can't get access to the grandchildre开发者_开发百科n 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.


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


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号