PDA

View Full Version : Append child *before* last child



michiel
30 Jun 2010, 3:15 AM
Hi guys,

I'm using the following code to append a node as the *last* node of a tree:



var newNode = new Ext.tree.TreeNode({ ... });
root.appendChild(newNode);


Now I'm wondering what would be the preferred way to add the new node *before* the last child?

I'm assuming I'd have to use "insertBefore", but then how do I retrieve the last node of the tree? I can't seem to find a specific function for that ..

Thanks! Michiel

Animal
30 Jun 2010, 3:22 AM
root.lastChild?

It's in the docs.

michiel
30 Jun 2010, 3:24 AM
Yup .. that's the one .. I was searching with the terms 'last+node' where I should have used 'last+child'