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

Showing nodes with parent id didn't exists in the list

1 Answer 90 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Firoz Ansari
Top achievements
Rank 1
Firoz Ansari asked on 04 Mar 2011, 05:13 PM

Hi,
I am working on a page which shows hirarchical records through RadTreeList control. Everything looks fine except records with parent id which didnt exists in list. Not sure if this is a limitation of RadTreeList control or if there is any flag which allow to display these kind of records.

I have many records in the table with parent id which didn't exists in the table but we still want to show those records in TreeList control.

To explain the issue, there is test page. As you can see in result, first record ("Appetizers") is not rendering on the page as parent id "Y", didn't exists in list.

Thank you in advance for your help.

Default.aspx

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"></telerik:RadAjaxLoadingPanel>
<telerik:RadTreeList ID="RadTreeList1" runat="server" OnNeedDataSource="RadTreeList1_NeedDataSource"
    ParentDataKeyNames="ParentID" DataKeyNames="ID" AllowPaging="true" PageSize="5"
    AutoGenerateColumns="false" AllowSorting="true">
    <Columns>
        <telerik:TreeListBoundColumn DataField="ID" UniqueName="ID" HeaderText="Category ID" />
        <telerik:TreeListTemplateColumn DataField="ProductName" UniqueName="ProductName" HeaderText="Product">
            <ItemTemplate>
                <%# Eval("ProductName")%>
            </ItemTemplate>
            <HeaderStyle Width="300px" />
        </telerik:TreeListTemplateColumn>
        <telerik:TreeListBoundColumn DataField="ParentID" UniqueName="ParentID" HeaderText="Parent Category ID" />
    </Columns>
</telerik:RadTreeList>

Default.aspx.cs
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void RadTreeList1_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
    {
        RadTreeList1.DataSource = MyData.GetData();
    }
}
public class MyData
{
    public static List<MyItem> GetData()
    {
        List<MyItem> list = new List<MyItem>();
        list.Add(new MyItem("A", "Appetizers", "Y"));
        list.Add(new MyItem("B", "Beverages", ""));
        list.Add(new MyItem("C", "Cheese", ""));
        return list;
    }
}
public class MyItem
{
    public string ID { get; set; }
    public string ProductName { get; set; }
    public string ParentID { get; set; }
    public MyItem(string id, string productName, string parentID)
    {
        ID = id;
        ProductName = productName;
        ParentID = parentID;
    }
}

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 07 Mar 2011, 01:08 PM
Hi Firoz,

RadTreeList does not currently support this scenario. Only items contaning default values, null and DbNull for their parent key names qualify as root items. We are planning to extend RadTreeList to support specification of custom values for root items in future versions, even though we cannot give any particular schedules for that.

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeList
Asked by
Firoz Ansari
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or