In ExtJS 4.1 I'm selecting a TreePanel node by its ID like this:
var n = myTreePanel.getStore().getNodeById(id);
myTreePanel.selectPath(n.getPath());
.. which seems like a lot of typing for such a simple operation. Is there a more concise way?
I don't believe there's a more concise way of writing that code that's built-in to the framework. You can always just write your own method and add it to the Tree class.
Ext.tree.Panel.addMembers({
selectPathById: function(id){
var me = this,
node = me.getStore().getNodeById(id);
if(node){
me.selectPath(node.getPath());
}
}
});
/* Later, in your own code */
myTreePanel.selectPathById(id);