Sunday, September 21, 2008

Have a parent node select all child nodes in WebTree

1. Handle the UltraWebTree.ClientSideEvents.NodeChecked event.
2. In this event, iterate through the selectedNode.getChildNodes array and select all child nodes.

Here is the JavaScript function to perform all this. Since the NodeChecked event is fired every time you call node.setChecked(), this event will fire recursively and take care of the whole hierarchy for you.

function UltraWebTree1_NodeChecked(treeId, nodeId, bChecked)
{
var selectedNode = igtree_getNodeById(nodeId);
var childNodes = selectedNode.getChildNodes();

if (bChecked)
{
for (n in childNodes)
{
childNodes[n].setChecked(true);
}
}
}

No comments: