PDA

View Full Version : deleting multiple nodes, tree


jstretch
05-10-2006, 07:00 AM
The following code loops through a view which contains multiple replicated tree nodes. Each tree node has a checkbox. If the checkbox value is true(checked) then I want to deleteNode on the datapath. This works fine when only one tree checkbox is selected. But when multiple are selected it only deletes the first one. Apparently when deleteNode is called, it bombs out of the loop..no error is shown in the debugger.


<view name="events">
<tree />
<tree />
....
</view>



var events = parent.parent.events.subviews;
for(i = 0; i < events.length; i++) {
if(events[i].treeitem.checked.getAttribute("value") == true) {
Debug.write(events[i].datapath);
var dp_tmp = events[i].datapath.deleteNode();
}
}



EDIT: I figured out that when you delete one of the trees, it has to recreate the entire tree..which in turn unchecks all the checkboxes. Workarounds?

jstretch
05-10-2006, 08:11 AM
Workaround:

Instead of deleting the nodes inside the loop, I added the datapath.dupePointer() to an array for each selected tree. Then I set the parent tree's datapath to null. Now I can loop through my new array, call deleteNode() on each pointer in the array, and then reset the parent tree's datapath to what it originally was.