View Full Version : Set treepanel pre-selected node

28 Sep 2011, 1:52 PM
I know this should be a small common thing and should already be documented somewhere, but I just can't find it.
I have a treepanel, I try to mark a node as selected before or right after the panel is rendered, so the node can be highlighted on panel display.
But when I have following line for the treepanel on-load listener (so the panel is rendered already, right?)


it throw me an error saying "Cannot read property 'length' of undefined". The error stack indicated the error was thrown from Ext.define.onSelectChange.
the treeNode is a valid node got from the panel tree with getNodeById, and I didn't see any error when getting the selection model from the panel component.

Do you see any problem with what I did, or know any other way to do the same thing?

28 Sep 2011, 3:54 PM
Resolved the problem by using afterrender. Everything works. A minor problem is, I still get error on the panel's getStore method, since the panel is wrapped as Ext.Component type. Looks Ext doesn't have type cast, not sure how to remove the error message.

6 Jan 2012, 8:14 AM
I know this was a few months ago, but what we're using is:

var appNav = Ext.create('Ext.property.NavTree'),

This sets the node: /root/node-myScreen/node-Me to selected when the app loads.