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

Possible to restrict multi-select to a specific node?

2 Answers 66 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Albert Pernia
Top achievements
Rank 1
Albert Pernia asked on 11 Oct 2009, 09:18 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 12 Oct 2009, 10:31 AM
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.
0
Albert Pernia
Top achievements
Rank 1
answered on 12 Oct 2009, 04:11 PM
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!
Tags
TreeView
Asked by
Albert Pernia
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Albert Pernia
Top achievements
Rank 1
Share this question
or