PDA

View Full Version : Ext Js Tree Panel Expand and Select a deeper node



jeralyn.j.de.ocampo
4 Feb 2014, 6:45 PM
I'm currently studying sencha ExtJs 4.0. In my study, I faced this issue with tree panel. I need to select a deeper node on a tree. I'm using the code below:


var root = Ext.getStore('Lists').getRootNode(), tree = Ext.getCmp('listTree'), selModel = tree.getSelectionModel();
selModel.select(root.findChild('key','1072',true);


I am aware that it is working but since it is a deeper node, its parent node is not being expanded and the node that is being sought is not highligted to show that it was selected.

Is this possible with Ext Js Tree Panel?

f.baron
5 Feb 2014, 12:17 AM
You could use a simple recursion to expand all the parent nodes of the one you want to select:



expandAllParents: function(node) {
while (node.parentNode !== null) {
node.parentNode.expand();
node = node.parentNode;
}
}

..

tree.getSelectionModel().select(leafToSelect);
this.expandAllParents(leafToSelect);