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

how to deselect telerik treeview node on form body click?

3 Answers 174 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Burepalli V S Rao
Top achievements
Rank 1
Burepalli V S Rao asked on 31 May 2012, 02:54 PM
Hi Friends,

i want to deselect the telerik treeview node on form body click using javascript?

how to do that?

thanks,
Burepalli V S Rao.

3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 04 Jun 2012, 08:57 AM
Hello,

 
You can use the unselectAllNodes function of the client object of RadTreeView when one clicks outside of it.

Hope this will help you.

All the best,
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.
0
SB
Top achievements
Rank 1
answered on 07 Jun 2012, 11:23 PM
Hi,

i want this only, but when i call this function like the below one

window.document.body.onclick = UnSelectAllNodes;
it is getting deselecting the nodes, but after that if i click on item then it has to select it, but it is not getting selected


Thanks,
Burepalli V S Rao.
0
Princy
Top achievements
Rank 2
answered on 08 Jun 2012, 08:48 AM
Hello Mohinder,

I have created a sample code based on your scenario. Please check the following code snippet.
aspx:
<form id="form1" runat="server" onclick="deselect();" style="background-color:Red;">
 <div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientNodeClicking="OnClientNodeClicking"  >
   <Nodes>
    <telerik:RadTreeNode Text="Node1"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Node2"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Node3"></telerik:RadTreeNode>
    <telerik:RadTreeNode Text="Node4"></telerik:RadTreeNode>
  </Nodes>
</telerik:RadTreeView>
</div>
</form>

JS:
<script type="text/javascript">
    var i;
    function deselect() {
    var tree = $find("<%= RadTreeView1.ClientID%>");
    if (i != 0) {
   tree.unselectAllNodes();
    }
      i = 1;
    }
    function OnClientNodeClicking(sender, args) {
        i = 0;
    }
</script>

Thanks,
Princy.
Tags
TreeView
Asked by
Burepalli V S Rao
Top achievements
Rank 1
Answers by
Plamen
Telerik team
SB
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or