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; } }