-
20 Nov 2007 7:17 AM #1
Programmatically Select TreeNode
Programmatically Select TreeNode
Hi,
I think this is simple question but I've been stuck on it for some time now. I have a treepanel and would like to be able to have a default selection. I first thought the selectPath method would be what I want, and that seems to work, but doesn't give any visual indication that a node is selected (highlighted). In the forums I have come accross references to node.ui.highlight() but that gives me 'Ext.fly(...) is null or not an object'.
What I would like to see is my treepanel with a node selected just as if the user just clicked on it.
Any help would be much appreciated.
Kevin
Ext Team: I am still very new to Ext but have been quite impressed, keep up the good work.
-
20 Nov 2007 7:21 AM #2
-
21 Nov 2007 8:06 AM #3
How witty...after a day of searching I figured I'd risk a question.
At any rate thanks for the link it got me going in the right direction.
For anyone else that reads this, function.defer() was what I needed.
Something I am still curious about, however, is why I needed to defer the call to TreePanel.selectPath(). I am calling it in the TreePanel's render event after building the tree, why does it need a pause? Is there another event I should be using so that I don't have to defer...maybe the window's render event (the tree is in a window)?
Thanks, kg
-
3 Feb 2008 5:23 PM #4
Yes I'd like to know the same thing - we shouldn't have to use defer. I note that TreeNode has no "render" event we can monitor. Is there any other way we can automatically select a treenode upon the tree panel rendering?
-
3 Feb 2008 11:14 PM #5
Code:if (Ext.getCmp('tree')) { // if tree is loaded var tree = Ext.getCmp('tree'); tree.on('append', function(tree, p, node){ if(node.id == 9){ // select node node.select.defer(100, node); } }); }
-
9 Sep 2009 1:05 AM #6
This is just great. Let's defer all the processing...
-
5 Sep 2011 9:44 PM #7
what in case of multiselectModel
what in case of multiselectModel
in MultiSelectModel its clearing all the selection model.......
-
8 Feb 2013 5:16 AM #8
Solution of above question
Solution of above question
If you have node id then try to get the node by id and then use as follows
taxonomyTreeLoader.on("load", function(){
if(isQueryExecutable && singleParamDynamicQuery &&docTypeCodeDynamciQuery.length>0){
var currentNode=taxonomyTree.getNodeById(docTypeNodeId);
if(currentNode.isLeaf()){
taxonomyTree.getSelectionModel().select(currentNode);
taxonomyTree.fireEvent("click", currentNode);
}
}
});





Reply With Quote