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

Radtreeview simple click on node

3 Answers 106 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Madjid
Top achievements
Rank 1
Madjid asked on 20 Jan 2012, 07:06 AM
Hi,
RadTreeView expands a node by clicking the plus button or by double clicking the text node.
I want to change this by just simple click on plus or text.
I tried this by handling the ClientNodeClicked event but it's not working
<
script language="javascript"> function ClientNodeClicked(sender, eventArgs) { var node = eventArgs.get_node(); node.toggle(); } </script>
I used the load on demand server side. when i clicked the text  the plus button changed to minus and when i click on minus button it open the node and next time i redo the same operation on the same node  it works (because is already loaded).
please help.

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Jan 2012, 10:11 AM
Hello,

Try the following.
JS:
<script type="text/javascript" >
   function OnClientNodeClicked(sender,args)
   {
       var nodes = sender.get_allNodes();
       for (var i = 0; i < nodes.length; i++)
         {
            if (nodes[i].get_nodes() != null)
              {
                nodes[i].expand();
              }
         }
    }
</script>

Thanks,
Princy.
0
Madjid
Top achievements
Rank 1
answered on 21 Jan 2012, 02:15 AM
Thank you Princy for your quick reply.
 still not working.

Thanks.
Madjid.
0
Plamen
Telerik team
answered on 24 Jan 2012, 03:23 PM
Hello Madjid,

 
Here is the code that I added to the LoadOnDemandModes demo to accomplish the same functionality:

protected void RadTreeView2_NodeClick(object sender, RadTreeNodeEventArgs e)
   {
       if (e.Node.Nodes.Count == 0)
       {
           PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSide);
       }
       else
       {
           e.Node.Expanded = true;
       }
   }

Hope this helps.
 Kind regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Madjid
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Madjid
Top achievements
Rank 1
Plamen
Telerik team
Share this question
or