-
10 Feb 2009 12:27 PM #1
Help removing a node from a tree
Help removing a node from a tree
I have the following code to remove a node for a tree:
If the node is a leaf with at least two leafs on the branch it works fine. However, when theCode:var options = { url:this.deleteUrl || this.url ,method:this.method ,scope:this ,callback:this.cmdCallback ,node:node ,params:{ cmd:'delete' ,file:this.getPath(node) } }; options.node.parentNode.removeChild(options.node);
node is a leaf and that is the only leaf then the leaf is removed but the parent node, which was a folder, is changed to a leaf. I would like for either the parent node to be removed as well or for the parent node to stay as afolder. Thanks for any help.Bruce Sklar
Senior User Experience Engineer
-
10 Feb 2009 12:36 PM #2
Why not use options.node.remove() to remove the node?
As far as making it a folder, you could try setting the leaf property to false after you do the remove. ie. parentNode.leaf = false.
-
10 Feb 2009 12:57 PM #3
I tried the following change:
I still get the same result.Code:var par = options.node.parentNode; options.node.parentNode.removeChild(options.node); par.leaf = false;
I also tried:
The node which was a folder is now a leaf and that is not what I want.Code:options.node.remove(); // this works parentNode.leaf = false; // this has no effect
Bruce Sklar
Senior User Experience Engineer


Reply With Quote