I saw a lot of threads talking about adding dynamic nodes to TreePanel using the getNodeById or getRootNode methods and appendChild methods.
For some reason, I'm not able to do it. I don't know if I'am doing something wrong or if this has something to do with Ext JS 3.4.
Can someone tell me if this is right?
{
xtype: 'treepanel',
id: 'testTreePanel',
autoScroll: true,
width: 250,
collapsible: true,
title: 'Navigation',
containerScroll: true,
enableDD: true,
useArrows: true,
collapsible: true,
region: 'west',
root: {
allowDrag: false,
allowDrop: false,
iconCls: 'cover',
id: 'testRootNode',
text: 'Root Node'
},
loader: {
}
}
Here is what I'm doing to add nodes dynamically -
var testNode = new Ext.tree.TreeNode({
id: 'node_1',
leaf: true,
text: 'Test Node Text 1',
allowDrag: false,
allowDrop: false
});
Ext.getCmp('testTreePanel').getRootNode().appendChild(testNode);
I see that the nodes have been added under the root, if I do -
Ext.getCmp('testTreePanel').getRootNode().childNodes
but I also notice that the root
has allowChildren: false
, loaded: false
, loading: true
and childrenRendered: false
All the threads I've seen say that appendChild should do the trick. I'm not sure if I'm missing something here.