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

"Tree view Problem "

2 Answers 68 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rahul Khinvasara
Top achievements
Rank 1
Rahul Khinvasara asked on 17 Mar 2010, 12:16 PM
HI,

I have used telerik treeview control.
Tree view is dynamically created, which depend on database values.
I have set multiselect property to "false".
Its working fine with single Tree view but when I display  more than one instance of tree view multiple selection is possible which is confusing to the user.I want only single node to  be clicked by the user.
I have attached image showing multiple selection.
I want one node to be selected at a time.
How can I achieve this ? Please suggest me.
 
Thanks.

2 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 19 Mar 2010, 06:41 PM
Hi Rahul Khinvasara,

You were very close with setting the MultipleSelect property to "false". However for more than one tree you'll need additional logic to clear the selection of a node in a tree when one is selected in another tree.
Here's the Javascript code for this:

function get_allRadTreeViews() {
               var allRadTreeViews = [];
               var allRadControls = $telerik.radControls;
               for (var i = 0; i < allRadControls.length; i++) {
                   var element = allRadControls[i];
                   if (Telerik.Web.UI.RadTreeView && element instanceof Telerik.Web.UI.RadTreeView) {
                       Array.add(allRadTreeViews, element);
                   }
               }
               return allRadTreeViews;
           }
           function OnClientNodeClickedHandler(sender, args) {
               for (var i = 0; i < get_allRadTreeViews().length; i++) {
                   var currentTree = get_allRadTreeViews()[i];
                   if (sender.get_id() != currentTree.get_id()) {
                       for (var k = 0; k < currentTree.get_selectedNodes().length; k++) {
                           var node = currentTree.get_selectedNodes()[k];
                           node.set_selected(false);
                       }
                   }
               }
           }

You can find the full code in the attached .zip file.

Please let me know if this was helpful.

Kind regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Rahul Khinvasara
Top achievements
Rank 1
answered on 20 Mar 2010, 11:06 AM
Thanks for the reply.It worked!!
Tags
TreeView
Asked by
Rahul Khinvasara
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Rahul Khinvasara
Top achievements
Rank 1
Share this question
or