Expand only selected node client side

4 posts, 0 answers
  1. Tejas Kan
    Tejas Kan avatar
    6 posts
    Member since:
    Oct 2009

    Posted 13 Sep 2011 Link to this post

    Hi,
    I have this situation where, when I click a button client-side(i.e the button onclick ) event, I would like to use javascript function to expand only those nodes that have been checked(ticked). Rest of the nodes to be collapsed.
    I am have tried a lot of diff tent ways however with no success.
    Can any one help or show me any other examples of a similar situation.

    Thanks in advance

    Tejas
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Sep 2011 Link to this post

    Hello Tejas kan,

    Try the following client side code to achieve your scenario.
    Javascript:
    function Expand()
    {
      var treeView = $find("<%=RadTreeView1.ClientID%>");
        var allNodes = treeView.get_allNodes();
      var temp;
      for (var i = 0; i < allNodes.length; i++)
          {
    temp = allNodes[i];
      if (temp.get_checked())
        {
        temp.expand();
        }
     else
        {
        temp.collapse();
        }
      }
     }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. DEBAL
    DEBAL avatar
    22 posts
    Member since:
    Oct 2012

    Posted 19 Mar 2012 Link to this post

    HI
    I have same problem , I have refresh button in my aspx page , now i want to show user after click on refresh button the treeview node expanded  that user last click on treeview before click on refresh button, I have used <asp:button id="refreshbutton" Onclientclick="Expand"/> but not working ,.......
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Oct 2012 Link to this post

    Hi,

    Here is the sample code that I tried based on your scenario which works as expected.

    JS:
    <script type="text/javascript">
     function OnClientClick()
     {
       var treeview = $find("<%=RadTreeView1.ClientID %>");
       treeview.get_selectedNode().expand();
       return false;
     }
    </script>

    Hope this helps.

    Thanks,
    Princy.
Back to Top