Hello,
I'm creating self-referencing hierarchy radgrid for menu permission and having some problem with populating data.
I want to display like below
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
After setting parentkeyname and keyname at SelfHierarchySetting, my child items display correctly under respective parent items.
But the problem is that those child items also display at parent level like below
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
Child Item 1.1
Child Item 1.2
Child Item 2.1
Child Item 2.2
How can I get rid of those additional child items instead of using TreeList control?
My data structure is as simple as shown in this help topic http://www.telerik.com/help/aspnet-ajax/grid-self-referencing-hierarchy.html.
I have prepared sample project and you can check below.
.aspx
.cs
Thanks in advanced.
Robin
I'm creating self-referencing hierarchy radgrid for menu permission and having some problem with populating data.
I want to display like below
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
After setting parentkeyname and keyname at SelfHierarchySetting, my child items display correctly under respective parent items.
But the problem is that those child items also display at parent level like below
Parent Item 1
- Child Item 1.1
- Child Item 1.2
Parent Item 2
- Child Item 2.1
- Child Item 2.2
Child Item 1.1
Child Item 1.2
Child Item 2.1
Child Item 2.2
How can I get rid of those additional child items instead of using TreeList control?
My data structure is as simple as shown in this help topic http://www.telerik.com/help/aspnet-ajax/grid-self-referencing-hierarchy.html.
I have prepared sample project and you can check below.
.aspx
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" AutoGenerateColumns="false"> <MasterTableView AllowSorting="true" DataKeyNames="ID, ParentID" Width="100%"> <SelfHierarchySettings ParentKeyName="ParentID" KeyName="ID" /> <Columns> <telerik:GridBoundColumn UniqueName="colName" DataField="Name" HeaderText="Menu Name"> <ItemStyle Width="100px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn UniqueName="colDesc" DataField="Description" HeaderText="Description"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings AllowExpandCollapse="true"> </ClientSettings> </telerik:RadGrid>.cs
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { RadGrid1.DataSource = GetDataTable(); } private DataTable GetDataTable() { DataTable l_Table = new DataTable(); l_Table.Columns.Add("ID"); l_Table.Columns.Add("Name"); l_Table.Columns.Add("Description"); l_Table.Columns.Add("ParentID"); l_Table.Rows.Add(new string[] { "1", "Menu 001", "Setup", null }); l_Table.Rows.Add(new string[] { "2", "Menu 002", "Inventory", null }); l_Table.Rows.Add(new string[] { "3", "Menu 003", "Reports", null }); l_Table.Rows.Add(new string[] { "4", "Menu 004", "User", "1" }); l_Table.Rows.Add(new string[] { "5", "Menu 005", "Item", "1" }); l_Table.Rows.Add(new string[] { "6", "Menu 006", "Item type", "1" }); l_Table.Rows.Add(new string[] { "7", "Menu 007", "UOM", "1" }); l_Table.Rows.Add(new string[] { "8", "Menu 008", "Issuing", "2" }); l_Table.Rows.Add(new string[] { "9", "Menu 009", "Receiving", "2" }); l_Table.Rows.Add(new string[] { "10", "Menu 010", "Item details report", "3" }); l_Table.Rows.Add(new string[] { "11", "Menu 011", "Inventory issuing details report","3" }); l_Table.Rows.Add(new string[] { "12", "Menu 012", "Inventory receiving details report" }); return l_Table; }Thanks in advanced.
Robin