PDA

View Full Version : Expand child node in tree after context menu click



TheBigOnion
19 May 2011, 12:04 PM
Hello all,
I am trying to expand a child node in a tree after I reload it. The only information I have when I click the context menu is the node url. (I think)

Here is what I have tried.


Ext.tree.tree_control.getRootNode().reload();
Ext.tree.tree_control.expandPath(Ext.tree.context_menu.node.attributes.id);


I want it to re-open to the child node I was on when I right click and used the context menu.

Thanks.

TheBigOnion
20 May 2011, 8:47 AM
Anyone?

TheBigOnion
24 May 2011, 12:37 PM
Any???

TheBigOnion
31 May 2011, 11:33 AM
Anyone?

skirtle
31 May 2011, 12:02 PM
Why would a context-menu on a node cause the entire tree to reload? Would it not make more sense to only reload that node and/or it's children?

Assuming you really do need to reload the entire tree, using expandPath() is fine but you can't just pass the id of the last node, it needs to be a path that includes all of the ancestors too. The nodes are loaded asynchronously so there's no way for it to know where your final node lives in the tree unless you provide a full path. Take a look at the docs for getPath() and setPath().


The only information I have when I click the context menu is the node url.

Could you explain this comment a little more, I don't understand what that means.