Expand nodes from client side

3 posts, 0 answers
  1. Alan
    Alan avatar
    10 posts
    Member since:
    May 2012

    Posted 12 Jun 2012 Link to this post

    How can I expand all nodes of a treeview on a button click from clientside. If any one is expanded do nothing.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jun 2012 Link to this post

    Hi Alan,

    Try the following javascript to achieve your scenario.

    JS:
    <script type="text/javascript" >
            function OnClientClick()
            {
                    var tree = $find("<%=RadTreeView1.ClientID %>");
                var flag = 0;
                var nodes = tree.get_allNodes();
                for (var i = 0; i < nodes.length; i++)
                {
                    if (nodes[i].get_expanded())
                    {
                        flag = 1;
                    }
                }
                if (flag == 0)
                {
                    for (var i = 0; i < nodes.length; i++)
                    {
                        nodes[i].expand();
                    }
                }
     
            }
        </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 12 Jun 2012 Link to this post

    .
Back to Top