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?
<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?