View Full Version : [FIXED-422][3.1] Tree node remove() acting strange

3 Jan 2010, 2:18 PM

I tried this on the example and it is not removing all the nodes.


gives an error then stops, if you keep using the above procedure it will remove several more then stop until there are none left. Strange.

TypeError: n is undefined

A temporary fix hint would be appreciated or a red face :"> if I am not doing this right ;)

3.1 is shaping up great btw, I been having a good play with Ext.direct and it is awesome, thanks a lot.


3 Jan 2010, 2:45 PM
This recursive function seems to do the trick:

var removeAllChildren = function(parent){

if(n && parent.hasChildNodes()){


14 Jan 2010, 4:29 AM
I'm also experiencing what seems to be a bug in 3.1.0.

Invoking this works once, but then fails on any attempt to remove siblings of aNode:

aNode.remove()I believe the error occurs in Ext.data.Node (ext-3.1.0/src/data/Tree.js):

remove : function(destroy) {
this.parentNode.removeChild(this, destroy);
return this;
The error in Firebug is this.parentNode is null.

I'm testing under Firefox 3.0.17.

15 Jan 2010, 12:29 AM
eachChild() doesn't make a copy of the children before processing them, so adding or removing children in the callback will break eachChild.

How does this work:

var childNodes = [].concat(tree.getNodeById('src').childNodes);
Ext.each(childNodes, function(n){

15 Jan 2010, 5:19 AM
To follow up on my post above:

I didn't get to the bottom of the problem but did avoid it by reorganising the structure of components.

I have a TreePanel and a 'content' CardLayout panel with sub CardLayout panels.

Originally each child panel in the content panel managed its own TreePanel node. Each new child panel was given a reference to its parent and was responsible for creating and removnig its own node.

My approach now is that the top level content panel manages the nodes and child panels do not have references to their own nodes.

I'm not sure if I experienced a bug or if in fact it was a misunderstanding on my part.

17 Jan 2010, 11:38 AM
@Jazor: I think you're talking about something completely different. If you feel there's an issue, please create a new thread with a proper bug report.

@OP: There should probably be a removeAll method on the Node class itself to handle this.

Stay tuned ;)

17 Jan 2010, 12:06 PM
I haven't been able to recreate the problem with a simple example, so more likely a bug in my code than an Ext JS bug.

And yes, I agree not a the same problem as Lobos. I was a bit hasty with my post.

17 Jan 2010, 6:48 PM
A new removeAll method was added in rev 5904.