PDA

View Full Version : Append child to a collapsed node



Tinki
26 Nov 2010, 7:14 AM
I have a tree with a hardcoded structure - all the nodes are described in the code of script.


routeTree = new Ext.tree.TreePanel({
autoScroll: true,
loader: new Ext.tree.TreeLoader({
preloadChildren: true
}),
useArrows: true,
style: {
height: '100%'
},
animate: true,
renderTo: 'treeHalf',
root: new Ext.tree.AsyncTreeNode(
{
text: 'A',
expanded: true,
children: [
{
text: 'B,
expanded: true,
children: [
{
text: 'C',
expanded: false,
children: [ BLABLABLA ]
}
]
}

]
}

)
});

When I try to appendChild() to a collspsed node (never opened before) - it works (I check the count of nodes with FireBug). But when I expand the parent node it shows me only hardcoded nodes, like I've haven't added anything.
I suspect it reads contents of the node from code, not from memory:-?
Any thoughts, how to appendChild to a collapsed node?

Condor
26 Nov 2010, 7:46 AM
An AsyncTreeNode loads when expanded, thereby removing any children.

Either configure your TreeLoader with clearOnLoad:false or use TreeNodes instead of AsyncTreeNodes.