PDA

View Full Version : Select root node of a treeloader



mihaip007
31 Aug 2010, 8:28 AM
Hi...!

I am struggeling a bit here, and I am sure I am doing something wrong here! I have loaded a tree panel with a treeloader from a json file..! Everything works perfectly. Except that I am struggeling to find a way to automatically select the root node..!

Is there a simple way to do it? Because I am not really coming right with this one...

Thanks in advance...
Mihai

finieousFingers
3 Sep 2010, 8:45 AM
To select the root node, add the following to your treePanel:



listeners: {
'afterrender': function(){
this.getSelectionModel().select(this.getRootNode());
}
}



In my case I needed to select the first node, after expanding the tree.

First I add this listener to the treePanel:



listeners: {
'afterrender': function(){
this.getRootNode().expand(true);
}
}



Then I add this listener to the root:




listeners: {
'expand': function(){
this.getOwnerTree().getSelectionModel().select(this.item(0));
}
}

jarrednicholls
3 Sep 2010, 9:18 AM
Thanks finieousFingers for sharing your solution!

mihaip007
7 Sep 2010, 2:15 AM
Hey guys - thank you so much for your help...! You guys rock! And yes it works like a charm :)

Mihai