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

Show TreeView in Expanded Mode

2 Answers 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kalpesh
Top achievements
Rank 1
Kalpesh asked on 20 Nov 2013, 07:06 AM
Hi

I have seen that, TreeNode has the property ExpandMode. My Scenarios is - I am binding TreeView from back-end by just providing data source (not creating tree nodes and adding it to treeview), also in design I have just placed TreeView.

Now, when my page is loaded and treeview is displayed, I want all nodes displayed in Expanded Mode. I am looking forward for a single property on TreeView level. I do not want/love to write any (C# or JS) code to iterate through and set expand mode.

Please provide your suggestion for this. Thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 20 Nov 2013, 09:40 AM
Hi Kalpesh,

Please try to use the server side  ExpandAllNodes() method for expanding all the nodes of the RadTreeView. Please have a look into the sample code I tried.

ASPX:
<telerik:RadTreeView ID="RadTreeView1" runat="server">
</telerik:RadTreeView>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadTreeView1.DataSourceID = "SqlDataSource1";
    RadTreeView1.DataFieldID = "id";
    RadTreeView1.DataFieldParentID = "parentid";
    RadTreeView1.DataTextField = "text";
    RadTreeView1.DataBind();
    // expand all the nodes
    RadTreeView1.ExpandAllNodes();
}

Thanks,
Shinu.
0
Kalpesh
Top achievements
Rank 1
answered on 20 Nov 2013, 11:38 AM
Thanks Shinu for this.

Actually after posting here ..I continued research and found that soln.

Thanks again for your quick reply.
Tags
TreeView
Asked by
Kalpesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Kalpesh
Top achievements
Rank 1
Share this question
or