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

Expand nodes from client side

2 Answers 35 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 12 Jun 2012, 06:07 AM
How can I expand all nodes of a treeview on a button click from clientside. If any one is expanded do nothing.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Jun 2012, 07:10 AM
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.
0
Shinu
Top achievements
Rank 2
answered on 12 Jun 2012, 07:11 AM
.
Tags
TreeView
Asked by
Alan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or