RadTreeView for ASP.NET

Checking child nodes when checking the parent node Send comments on this topic.
See Also
Using Checkboxes > Client-side checkbox support > Checking child nodes when checking the parent node

Glossary Item Box

The AfterClientCheck property of the treeview specifies which JavaScript function will be called client-side upon node checking. The function accepts a single parameter - the instance of the node checked, e.g.

  Copy Code
<rad:RadTreeView runat="server" CheckBoxes="True" AfterClientCheck="AfterCheck" />

In the client-side event handler, you can obtain reference to the parent node and hence all the child-nodes in the parent collection check/uncheck all nodes.

For example:

  Copy Code
<script language=javascript>

function UpdateAllChildren(nodes, checked)
{
var i;
for (i=0; i<nodes.length; i++)
{
 
if (checked)
 {
  
nodes[i].Check();
 }
 
else
 {
  
nodes[i].UnCheck();
 }
 
if (nodes[i].Nodes.length > 0)
 {
  
UpdateAllChildren(nodes[i].Nodes, checked);
 }
}
}
function AfterCheck(node)
{
UpdateAllChildren(node.Nodes, node.Checked);
}
</script>

See Also