This is a migrated thread and some comments may be shown as answers.

Setting nodes children to checked in onclientnodechecking

1 Answer 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
KevinMc
Top achievements
Rank 1
KevinMc asked on 23 Jul 2008, 05:18 AM
I am trying to set the checked state to true on the children of a tree node when the parent is checked. Following is the treeview and javascript function i tried. Can someone review to make sure the syntax is correct and provide input on whether it whould work?

 <telerik:RadTreeView ID="treeProducts" runat="server" CheckBoxes="true" 
 DataFieldID="ProductID" DataFieldParentID="ParentProductID" DataSourceID="odsProducts" 
 DataTextField="ProductName" DataValueField="ProductID" 
 OnClientNodeChecking="ProductChecking">  
</telerik:RadTreeView> 

function ProductChecking(sender, eventArgs)  
{  
     var node = eventArgs.get_node()  
     if(node.get_nodes().get_count() > 0)    
     {    
          for (var i=0; i<node.get_nodes().get_count();i++)    
          {          
               var childnode = node.get_nodes().getNode(i);          
               childnode.set_checked(true);    
          }  
     }  

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 23 Jul 2008, 07:27 AM
Hi KevinMc,

The syntax seems correct, but I think it will check only the direct child nodes of the node.

I suggest that you check this how-to article:
Checking/Unchecking All Child Nodes

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
KevinMc
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or