Good Afternoon,
I am currently working on a project at work and we are using the RadGrid to display some hierarchical information. All works fine except for binding to a list that is contained within the primary class. I have the following:
Approver Class:
---------------------
Product Class:
-------------------
public class BOC_Product
{
public BOC_Product()
{
Approvers = new List<BOC_Approver>();
}
Rad Grid Setup:
---------------------
<telerik:RadGrid ID="gridNewHireRequests" runat="server" CssClass="MyGridControl" GridLines="None" AutoGenerateColumns="False"
OnNeedDataSource="gridNewHireRequests_NeedDataSource" >
<ClientSettings>
<Scrolling AllowScroll="True" ScrollHeight="100%" UseStaticHeaders="false" />
</ClientSettings>
<MasterTableView DataKeyNames="ProductID" CommandItemDisplay="Top">
<CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false" />
<DetailTables>
<telerik:GridTableView DataKeyNames="ProductID" Width="100%" runat="server">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ProductID" MasterKeyField="ProductID" />
</ParentTableRelation>
<Columns>
<telerik:GridBoundColumn DataField="Approvers.ApproverID" HeaderText="Approver ID" UniqueName="ApproverID" />
<telerik:GridBoundColumn DataField="Approvers.ApproverName" HeaderText="Approver Name" UniqueName="ApproverName" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn DataField="ProductID" HeaderText="Product ID" UniqueName="ProductID" />
<telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" UniqueName="ProductName" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
If the Approvers List in the Product class was just another class I can get this to work no issues, but because the Approvers property in the Product class is a list I am unsure how to get it to bind in the subgrid. At the moment if throws an error with unknown fields of course.
is there a standard way to handle binding if a list that each element contains another list?
Thanks, Any help would be appreciated.
Chris Eisnaugle
I am currently working on a project at work and we are using the RadGrid to display some hierarchical information. All works fine except for binding to a list that is contained within the primary class. I have the following:
Approver Class:
---------------------
public class BOC_Approver
{
public BOC_Approver()
{
}
public BOC_Approver(Int32 MyApproverID, String MyApproverName)
{
ApproverID = MyApproverID;
ApproverName = MyApproverName;
}
public Int32 ApproverID { get; set; }
public String ApproverName { get; set; }
}
Product Class:
-------------------
public class BOC_Product
{
public BOC_Product()
{
Approvers = new List<BOC_Approver>();
}
public BOC_Product(Int32 MyProductID, String MyName) : this()
{
ProductID = MyProductID;
ProductName = MyName;
}
public Int32 ProductID { get; set; }
public String ProductName { get; set; }
public List<BOC_Approver> Approvers { get; set; }
}
Rad Grid Setup:
---------------------
<telerik:RadGrid ID="gridNewHireRequests" runat="server" CssClass="MyGridControl" GridLines="None" AutoGenerateColumns="False"
OnNeedDataSource="gridNewHireRequests_NeedDataSource" >
<ClientSettings>
<Scrolling AllowScroll="True" ScrollHeight="100%" UseStaticHeaders="false" />
</ClientSettings>
<MasterTableView DataKeyNames="ProductID" CommandItemDisplay="Top">
<CommandItemSettings ShowAddNewRecordButton="true" ShowRefreshButton="false" />
<DetailTables>
<telerik:GridTableView DataKeyNames="ProductID" Width="100%" runat="server">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="ProductID" MasterKeyField="ProductID" />
</ParentTableRelation>
<Columns>
<telerik:GridBoundColumn DataField="Approvers.ApproverID" HeaderText="Approver ID" UniqueName="ApproverID" />
<telerik:GridBoundColumn DataField="Approvers.ApproverName" HeaderText="Approver Name" UniqueName="ApproverName" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn DataField="ProductID" HeaderText="Product ID" UniqueName="ProductID" />
<telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" UniqueName="ProductName" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
If the Approvers List in the Product class was just another class I can get this to work no issues, but because the Approvers property in the Product class is a list I am unsure how to get it to bind in the subgrid. At the moment if throws an error with unknown fields of course.
is there a standard way to handle binding if a list that each element contains another list?
Thanks, Any help would be appreciated.
Chris Eisnaugle