Show TreeView in Expanded Mode

3 posts, 1 answers
  1. Kalpesh
    Kalpesh avatar
    8 posts
    Member since:
    Nov 2013

    Posted 20 Nov 2013 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kalpesh
    Kalpesh avatar
    8 posts
    Member since:
    Nov 2013

    Posted 20 Nov 2013 Link to this post

    Thanks Shinu for this.

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

    Thanks again for your quick reply.
Back to Top