"Tree view Problem "

3 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 17 Mar 2010 Link to this post


    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.
  2. Veronica
    Veronica avatar
    1213 posts

    Posted 19 Mar 2010 Link to this post

    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];

    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.
  3. DevCraft R3 2016 release webinar banner
  4. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 20 Mar 2010 Link to this post

    Thanks for the reply.It worked!!
Back to Top