How to remove all children of a tree node

This is an archived post from the ExtJS era — the code may be obsolete, but the principles often still apply.

Code in this post can be obsolete, however, principles and theory may still apply.

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

That's all there is to it

14 comments

  1. blablamanMarch 8, 2009archive
    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
  2. SakiMarch 9, 2009archive
    No, I haven't made Ext WordPress theme.
  3. Edgar MeijMarch 22, 2009archive
    Nice! I was looking for this, thanks.
  4. nadavMarch 25, 2009archive
    Awesome, really helped me, thanks!
  5. TCLSeptember 1, 2009archive
    while(node.firstChild && node.firstChild.remove());
  6. website designing pakistanJanuary 10, 2010archive
    Very interesting and informative site! Good job done by you guys, Thanks
  7. SeanMay 11, 2010archive
    This works, thanks. Love your site!
  8. SteveMay 31, 2010archive
    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.
  9. solovieffJuly 12, 2010archive
    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 );
  10. Anish SnehJanuary 28, 2011archive
    Thanks mate, saved my day... -- Anish Sneh
  11. FarishJuly 4, 2011archive
    Ext.getCmp('treeid').getRootNode().removeAll();
  12. FarishJuly 4, 2011archive
    use without the backslash in the getCmp
  13. K.rajuJune 26, 2012archive
    thankyou!!!!!!!
  14. MimmoJanuary 22, 2013archive
    When i remove all children the icon of folder change, how can i do to avoid this?

Comments are closed on archived posts.