How to remove all children of a tree node

4. March 2009 – 23:34

Suppose we want to remove all children of the node node:

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

That’s all there is to it


StumbleUpon Toolbar
  1. 12 Responses to “How to remove all children of a tree node”

  2. are you the maker of the extjs wordpress template?

    i like it and i see the features of 2.0?
    is this still under development??

    greets

    By blablaman on Mar 8, 2009

  3. No, I haven’t made Ext WordPress theme.

    By Saki on Mar 9, 2009

  4. Nice! I was looking for this, thanks.

    By Edgar Meij on Mar 22, 2009

  5. Awesome, really helped me, thanks!

    By nadav on Mar 25, 2009

  6. while(node.firstChild && node.firstChild.remove());

    By TCL on Sep 1, 2009

  7. Very interesting and informative site! Good job done by you guys, Thanks

    By website designing pakistan on Jan 10, 2010

  8. This works, thanks. Love your site!

    By Sean on May 11, 2010

  9. Just to bring to ppls attention, there\’s a new removeAll method on the tree node. Looks like its only in version 3.2 and not 3.1 (worked that out the hard way). removeChild also doesn\’t work in 3.1 but fixed in 3.2.

    By Steve on May 31, 2010

  10. Hi, I am trying to remove the nodes like in your example and than add them again. Firstly I have a memory leak after that, and also sometimes i have an awfull “this.target is null
    error source line: [Break on this error] Ext.ToolTip=Ext.extend(Ext.Tip,{showDe…ithin(this.target.dom,true)){return;}” error );

    By solovieff on Jul 12, 2010

  11. Thanks mate, saved my day…

    – Anish Sneh

    By Anish Sneh on Jan 28, 2011

  12. Ext.getCmp(\’treeid\’).getRootNode().removeAll();

    By Farish on Jul 4, 2011

  13. use without the backslash in the getCmp

    By Farish on Jul 4, 2011

Post a Comment