PDA

View Full Version : TreePanel childNodes Array is empty!!!!



taxidriver
20 Jul 2010, 2:31 AM
Hello guys!

I have a Ext.tree.Treepanel and when it is first loaded the root node is collapsed but the json data (rest nodes) have already been loaded.
The weird thing is that when I call Ext.getCmp('treepanelID').getNodeById(rootId').childNodes; or for any other node the childNodes Array is empty!!!!!

BUT when I expand this node and collapse again the above expression returns a valid Array!!!

Have you any ideas?

Thank you!

Animal
20 Jul 2010, 2:48 AM
It's an AsyncTreeNode. It only loads (either from Ajax, or from the configured "children" property) when it needs to: on first expand.

!!!!!

taxidriver
20 Jul 2010, 3:21 AM
Thank you very much Animal!

I'll try to get the necessary information by the expression Ext.getCmp('treepanelID').getNodeById('rootId').attributes.children;

Condor
20 Jul 2010, 3:30 AM
So your server already returns all children for the root node in the first request? In that case you should configure the TreeLoader with preloadChildren:true.

taxidriver
20 Jul 2010, 4:07 AM
Thank you very much Condor for your suggestion.

The server actually returns all the children in the first request, without having setting the config option preloadChildren:true.
Is it necessary this config option in order to avoid any problems?

Condor
20 Jul 2010, 4:16 AM
Only for the problem you were having (not being able to access the children before the node is expanded).