RadTreeList Expan

6 posts, 0 answers
  1. Hardik
    Hardik avatar
    3 posts
    Member since:
    Nov 2011

    Posted 27 Aug 2013 Link to this post

    Hello All

    I have a RadTreeList in my page and I have requirement to expand all the levels of the list.

    I have searched a lot and found method of tree list ExpandAll() and collepseAll() but not working on my case.

    So is there any way to do this or is there any way to do it manually?

    thanks

    Hardik
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Aug 2013 Link to this post

    Hi Hardik,

    Please try the following code snippet to expand the items manually.

    ASPX:
    <telerik:RadTreeList ID="RadTreeList2" AutoGenerateColumns="false" runat="server"
        AllowPaging="True" DataSourceID="SqlDataSource1" DataKeyNames="EmployeeID" ParentDataKeyNames="ReportsTo"
        PageSize="5">
        <PagerStyle Position="TopAndBottom" Mode="Slider"></PagerStyle>
        <Columns>
            <telerik:TreeListBoundColumn DataField="EmployeeID" HeaderText="EmployeeID">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="LastName" HeaderText="LastName">
            </telerik:TreeListBoundColumn>
            <telerik:TreeListBoundColumn DataField="ReportsTo" HeaderText="ReportsTo">
            </telerik:TreeListBoundColumn>
        </Columns>
    </telerik:RadTreeList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [EmployeeID], [LastName], [ReportsTo] FROM [EmployeeDetails]">
    </asp:SqlDataSource>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (var items in RadTreeList2.Items)
        {
            items.Expanded = true;
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hardik
    Hardik avatar
    3 posts
    Member since:
    Nov 2011

    Posted 28 Aug 2013 Link to this post

    Hi Shinu

    thanks for the answer but still not working.

    Actually I am i want to expand upto multiple levels
    See the below image.



    I am binding the radtreelist from the server side(not having the sql data source).

    Any idea?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 29 Aug 2013 Link to this post

    Hi Hardik,

    Please have a look at the following code snippet which works fine at my end. For me ExpandAllItems() is expanding multiple levels of the RadTreeList. I am not able to replicate your issue.

    ASPX:
    <telerik:RadTreeList ID="RadTreeList1" AutoGenerateColumns="true" runat="server"
        DataKeyNames="EmployeeID" ParentDataKeyNames="ReportsTo" OnNeedDataSource="RadTreeList1_NeedDataSource">
    </telerik:RadTreeList>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadTreeList1.ExpandAllItems();
    }
    public DataTable GetDataTable()
    {
        String ConnString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand("SELECT EmployeeID, LastName, City, ReportsTo FROM EmployeeDetails", conn);
        DataTable myDataTable = new DataTable();
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
        return myDataTable;
    }
    protected void RadTreeList1_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
    {
        RadTreeList1.DataSource = GetDataTable();
    }

    Please provide your entire code if it doesn't help you.
    Thanks,
    Shinu.
  6. Hardik
    Hardik avatar
    3 posts
    Member since:
    Nov 2011

    Posted 02 Sep 2013 Link to this post

    Hi shinu

    Thanks again for the reply..

    It is working but it expands only up to second level that is (category 2_1_1) but not not all the levels.
    see the below image



    So I want to expand up to N levels.

    Also I am binding parent categories first and to bind the child categories I am using "ChildItemsDataBind" event of the rad tree list.

    So is there any way that I can expand up to all levels to where it find the child categories.

    Thanks
    Hardik
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Sep 2013 Link to this post

    Hi Hardik,

    Unfortunately I am not able to replicate the issue at my end. Please provide your complete code.

    Thanks,
    Shinu
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017