Possible to restrict multi-select to a specific node?

3 posts, 1 answers
  1. Albert Pernia
    Albert Pernia avatar
    2 posts
    Member since:
    Sep 2009

    Posted 11 Oct 2009 Link to this post

    Hello all,

    New user to Telerik controls here.  Question on RadTree...is it possible to enable multi-select, but restrict selections to a given node?  And only the immediate children of that node?

    So for example, if there are 3 parent nodes, each with 5 child nodes.  If a user select 2 child nodes of Parent 1, but then selects a child node of parent 2, all the selected nodes in Parent 1 would be unchecked.  The user could continue to multi-select children in Parent Node 2.  And so on.

    Any help is appreciated.  Thanks in advance.
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Oct 2009 Link to this post

    Hi Albert Pernia,

    Try the following client-side code to accomplish the functionality.

    JavaScript:
     
    <script type="text/javascript" language="javascript"
    function ClientNodeChecked(sender, eventArgs) 
          var tree = sender;   
      var node = eventArgs.get_node(); 
        var parentNode=node.get_parent(); 
         for(j=0;j<tree.get_checkedNodes().length;j++) 
         { 
            if(tree.get_checkedNodes()[j].get_parent().get_text()!=node.get_parent().get_text()) 
            { 
                tree.get_checkedNodes()[j].set_checked(false); 
                j--; 
            } 
            else 
            { 
                tree.get_checkedNodes()[j].set_checked(true); 
            } 
         } 
    </script>  

    -Shinu.
  3. Albert Pernia
    Albert Pernia avatar
    2 posts
    Member since:
    Sep 2009

    Posted 12 Oct 2009 Link to this post

    Ah, yes, thank you very much, that works perfectly.  I started to play around with the client-side functionality when I realized there was no property in the RadTree you could set to restrict the selections.  But this saves me the trouble.  Thanks alot!
Back to Top