PDA

View Full Version : root node method



wp.joju
11 Feb 2010, 9:46 PM
why is it that if i do this i get a script error object does not support this method




Ext.getCmp('directorytree').getRootNode().removeAll(true);



Ext.getCmp('directorytree') is a treepanel

Eugen_
11 Feb 2010, 10:36 PM
It should work. Maybe Ext.getCmp('directorytree') is not a treepanel?

Use a



var yourTreePanel = new Ext.tree.TreePanel({
...
});
and



yourTreePanel.getRootNode().removeAll();
without Ext.getCmp()


You can try to change ExtJs Tree Panel sample (http://www.extjs.com/deploy/dev/examples/tree/reorder.html). Add this to new Tree.TreePanel(



,
tbar: [{
text: 'Remove all',
handler: function() {
this.ownerCt.ownerCt.getRootNode().removeAll();
}
}]
It works

wp.joju
11 Feb 2010, 10:54 PM
Ext.getCmp('directorytree') is definitely a treepanel, i tried doing Ext.getCmp('directorytree').getXType() and it results to "treepanel".... i cannot use var yourTreePanel = new Ext.tree.TreePanel({ ...
}); since the "removeAll" function is situated in a different function

wp.joju
11 Feb 2010, 10:56 PM
i can do
Ext.getCmp('directorytree').getRootNode().appendChild(Ext.decode(directoryjson))

but not
Ext.getCmp('directorytree').getRootNode().removeAll();

wp.joju
11 Feb 2010, 11:04 PM
i've checked the API, why is it that the removeAll method is listed under
Ext.data.Tree and not Ext.tree

Eugen_
11 Feb 2010, 11:18 PM
try this



var node = Ext.getCmp('directorytree').getRootNode();

while (node.firstChild) {
node.removeChild(node.firstChild);
}