I'm pretty sure I'm just doing something incorrectly, but here we go.
I'm trying to get a self-referencing hierarchy grid where the first grid and it's hierarchy is linked by ID and DirectParent and its second hierarchy is linked by ChildID and DirectParent so you'd have:
Ben
Ralph
Ralph's Age
Ralph's Eye Color
Betty
Ruth
Ruth's Height
Ruth's Shoe Size
David
David's Age
Sam
Beth
Beth's Blood Type
If the lines in the ASPX below are uncommented then the structure is there, but on the second level, it's like the entire data source just comes out on that line. If you leave in the commenting lines in then you can see what I want, but only for the first and second levels, but not the third. What am I doing wrong here? I also have this "MyRadGrid.MasterTableView.FilterExpression = "DirectParent IS NULL";" in the page load method. I've tried setting a filter on the detail tables, but nothing. Any suggestions are appreciated.
I'm working with a DataTable with Data that resembles this form:
Columns: ID, ChildID, Name, Value, DirectParent
And my ASPX is as follows
Also, please excuse the structure of this DataTable. It isn't representative of any crazy database where IDs aren't unique.
I'm trying to get a self-referencing hierarchy grid where the first grid and it's hierarchy is linked by ID and DirectParent and its second hierarchy is linked by ChildID and DirectParent so you'd have:
Ben
Ralph
Ralph's Age
Ralph's Eye Color
Betty
Ruth
Ruth's Height
Ruth's Shoe Size
David
David's Age
Sam
Beth
Beth's Blood Type
If the lines in the ASPX below are uncommented then the structure is there, but on the second level, it's like the entire data source just comes out on that line. If you leave in the commenting lines in then you can see what I want, but only for the first and second levels, but not the third. What am I doing wrong here? I also have this "MyRadGrid.MasterTableView.FilterExpression = "DirectParent IS NULL";" in the page load method. I've tried setting a filter on the detail tables, but nothing. Any suggestions are appreciated.
I'm working with a DataTable with Data that resembles this form:
Columns: ID, ChildID, Name, Value, DirectParent
myData.Rows.Add(0, 0,
"Ben"
,
"has no kids"
, DBNull.Value);
myData.Rows.Add(1, 0,
"Ralph"
,
"has no kids"
, DBNull.Value);
myData.Rows.Add(2, 0,
"Betty"
,
"is a mother"
, DBNull.Value);
myData.Rows.Add(3, 0,
"David"
,
"is a father"
, DBNull.Value);
myData.Rows.Add(0, 0,
"Ralph's Age"
,
"33"
, 1);
myData.Rows.Add(0, 0,
"Ralph's Eye Color"
,
"Red"
, 1);
myData.Rows.Add(0, 0,
"David's Age"
,
"77"
, 3);
myData.Rows.Add(0, 4,
"Sam"
,
"is David's son"
, 3);
myData.Rows.Add(0, 5,
"Beth"
,
"is David's daughter"
, 3);
myData.Rows.Add(0, 6,
"Ruth"
,
"is Betty's daughter"
, 2);
myData.Rows.Add(0, 0,
"Beth's Blood Type"
,
"O+"
, 5);
myData.Rows.Add(0, 0,
"Ruth's Height"
,
"82 inches"
, 6);
myData.Rows.Add(0, 0,
"Ruth's Shoe Size"
,
"10"
, 6);
And my ASPX is as follows
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<%-- Old, but working
<
rad:RadGrid
runat
=
"server"
ID
=
"MyRadGrid"
OnNeedDataSource
=
"MyRadGrid_NeedDataSource"
MasterTableView-HierarchyLoadMode
=
"Client"
OnPreRender
=
"MyRadGrid_PreRender"
>
<
MasterTableView
HierarchyDefaultExpanded
=
"true"
HierarchyLoadMode
=
"Client"
DataKeyNames
=
"TheParent, GUID"
FilterExpression
=
"TheParent = 0"
ShowHeadersWhenNoRecords
=
"false"
>
<
SelfHierarchySettings
ParentKeyName
=
"TheParent"
KeyName
=
"GUID"
MaximumDepth
=
"3"
/>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
></
ClientSettings
>
</
rad:RadGrid
>
--%>
<
rad:RadGrid
runat
=
"server"
ID
=
"MyRadGrid"
OnNeedDataSource
=
"MyRadGrid_NeedDataSource"
MasterTableView-HierarchyLoadMode
=
"Client"
OnPreRender
=
"MyRadGrid_PreRender"
>
<
MasterTableView
HierarchyDefaultExpanded
=
"true"
HierarchyLoadMode
=
"Client"
DataKeyNames
=
"DirectParent, ID"
ShowHeadersWhenNoRecords
=
"false"
>
<
SelfHierarchySettings
ParentKeyName
=
"DirectParent"
KeyName
=
"ID"
MaximumDepth
=
"3"
/>
<%--
<
DetailTables
>
<
rad:GridTableView
HierarchyDefaultExpanded
=
"true"
HierarchyLoadMode
=
"Client"
DataKeyNames
=
"DirectParent, ChildID"
ShowHeadersWhenNoRecords
=
"false"
>
<
SelfHierarchySettings
ParentKeyName
=
"DirectParent"
KeyName
=
"ChildID"
MaximumDepth
=
"1"
/>
</
rad:GridTableView
>
</
DetailTables
>
--%>
</
MasterTableView
>
<
ClientSettings
AllowExpandCollapse
=
"true"
></
ClientSettings
>
</
rad:RadGrid
>
</
div
>
</
form
>
</
body
>
</
html
>
Also, please excuse the structure of this DataTable. It isn't representative of any crazy database where IDs aren't unique.