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

RadTreeList Expan

5 Answers 161 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Hardik
Top achievements
Rank 1
Hardik asked on 27 Aug 2013, 01:31 PM
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

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 28 Aug 2013, 04:52 AM
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.
0
Hardik
Top achievements
Rank 1
answered on 28 Aug 2013, 11:36 AM
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?
0
Shinu
Top achievements
Rank 2
answered on 29 Aug 2013, 08:20 AM
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.
0
Hardik
Top achievements
Rank 1
answered on 02 Sep 2013, 10:45 AM
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
0
Shinu
Top achievements
Rank 2
answered on 02 Sep 2013, 11:20 AM
Hi Hardik,

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

Thanks,
Shinu
Tags
TreeList
Asked by
Hardik
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Hardik
Top achievements
Rank 1
Share this question
or