Learn from Saki

Knowledge is power

This content is for registered users only. Please login.
Hello! To access your account, please Log in. Not a member? Sign up
  • Videos
  • Blog
  • Examples
  • Services
  • Add-ons
  • About

How to remove all children of a tree node

March 4, 2009 by saki 14 Comments

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:
1
2
3
while(node.firstChild) {
    node.removeChild(node.firstChild);
}
That’s all there is to it
  • Author
  • Recent Posts
Follow me:
saki
I'm a well seasoned developer, consultant and educator of web applications based mainly on Sencha libraries, PHP, MySQL and Node.js. Besides (Apple) computers, I love photography and mountain biking.
Follow me:
Latest posts by saki (see all)
  • Ext, Angular, React, and Vue - June 27, 2019
  • The Site Resurgence - February 11, 2018
  • Configuring ViewModel Hierarchy - June 19, 2015

Filed Under: Know-how Tagged With: extjs, javascript, Know-how

Comments

  1. blablaman says

    March 8, 2009 at 2:22 pm

    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

    Log in to Reply
  2. Saki says

    March 9, 2009 at 3:34 pm

    No, I haven’t made Ext WordPress theme.

    Log in to Reply
  3. Edgar Meij says

    March 22, 2009 at 10:16 pm

    Nice! I was looking for this, thanks.

    Log in to Reply
  4. nadav says

    March 25, 2009 at 10:53 am

    Awesome, really helped me, thanks!

    Log in to Reply
  5. TCL says

    September 1, 2009 at 9:58 pm

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

    Log in to Reply
  6. website designing pakistan says

    January 10, 2010 at 5:58 pm

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

    Log in to Reply
  7. Sean says

    May 11, 2010 at 9:15 pm

    This works, thanks. Love your site!

    Log in to Reply
  8. Steve says

    May 31, 2010 at 2:11 pm

    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.

    Log in to Reply
  9. solovieff says

    July 12, 2010 at 6:37 pm

    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 );

    Log in to Reply
  10. Anish Sneh says

    January 28, 2011 at 5:59 am

    Thanks mate, saved my day…

    — Anish Sneh

    Log in to Reply
  11. Farish says

    July 4, 2011 at 3:56 pm

    Ext.getCmp(‘treeid’).getRootNode().removeAll();

    Log in to Reply
  12. Farish says

    July 4, 2011 at 3:57 pm

    use without the backslash in the getCmp

    Log in to Reply
  13. K.raju says

    June 26, 2012 at 2:30 pm

    thankyou!!!!!!!

    Log in to Reply
  14. Mimmo says

    January 22, 2013 at 12:35 pm

    When i remove all children the icon of folder change, how can i do to avoid this?

    Log in to Reply

We will be happy to hear back from you Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Categories

  • Addons (2)
  • Architecture (14)
  • Examples (2)
  • ExtJS (26)
  • Howtos (16)
  • Javascript (1)
  • Know-how (32)
  • Linux (1)
  • Mac OS X (2)
  • SASS/CSS (2)
  • Snippets (9)
  • Theory (14)
  • Touch (6)
  • Tutorials (5)
  • What is a … (9)

Tag cloud

abstract class accordion application button class cluster column component config css definition deprecated design education event example extension extjs factory function form grid html initComponent items javascript Know-how knowledge layout Linux listener mysql old panel pattern php plugin render snippet sql sqlite state table touch tree viewpoint

Membership

Become a Member
Affiliate Program

Support

FAQ
Contact

Legal

Terms and Conditions
Licensing
Privacy Policy

Copyright © 2021 · Dynamik-Gen on Genesis Framework · WordPress · Log in