RadTreeview Check/Uncheck Childnodes to Parentnodes

2 posts, 0 answers
  1. Minesh
    Minesh avatar
    7 posts
    Member since:
    Apr 2007

    Posted 25 Apr 2009 Link to this post


    Here, i gave client side check/uncheck node child node to parent node as well as parent to child..


     <script type="text/javascript" language="javascript">      
        
     function UpdateAllChildren1(nodes, checked)
    {
       var i;
       for (i=0; i<nodes.get_count(); i++)
       {
       
           if (checked)
           {           
               nodes.getNode(i).check();
           }
           else
           {
               nodes.getNode(i).set_checked(false);
           }
           
           if (nodes.getNode(i).get_nodes().get_count()> 0)
           {          
               UpdateAllChildren1(nodes.getNode(i).get_nodes(), checked);         
                            
           }
       }
    }
         
     function Checkparentnode(node, isChecked,eventArgs)
     {
                
        if(node.get_parent() != null)
        {
          if(isChecked)
          {
            node.get_parent().set_checked(true);
            Checkparentnode(node.get_parent(), isChecked,eventArgs);
          }
          else
          {
              node.get_parent().set_checked(false);
              Checkparentnode(node.get_parent(), isChecked,eventArgs);
          }
        }            

     }
         
    function AfterCheck(childNodes, isChecked,eventArgs)
    {          
            
        UpdateAllChildren1(childNodes, isChecked);    
        var node = eventArgs.get_node();
        var parentNode = node.get_parent();    
        var cNodes = eventArgs.get_node().get_nodes();        
        Checkparentnode(node, isChecked,eventArgs);      

    }

    function clientNodeChecked1(sender, eventArgs)
    {
       var childNodes = eventArgs.get_node().get_nodes();   
       var isChecked = eventArgs.get_node().get_checked();
       AfterCheck(childNodes, isChecked,eventArgs);

    }
          
    </script>
      <telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="True"  OnClientNodeChecked="clientNodeChecked1" >
       </telerik:RadTreeView>
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Apr 2009 Link to this post

    Hello Steinar Simonsen,

    Do you have any problems with the code?

    Regards,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top