how to deselect telerik treeview node on form body click?

4 posts, 0 answers
  1. Burepalli V S Rao
    Burepalli V S Rao avatar
    23 posts
    Member since:
    Oct 2009

    Posted 31 May 2012 Link to this post

    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.
  2. Plamen
    Admin
    Plamen avatar
    2730 posts

    Posted 04 Jun 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohinder Goswami
    Mohinder Goswami avatar
    24 posts
    Member since:
    Nov 2008

    Posted 07 Jun 2012 Link to this post

    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.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Jun 2012 Link to this post

    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.
Back to Top