I'm looking for some help on binding a Codefluent entitycollection with an Infragistics WebHierarchicalDataGrid (v14.2). For illustrative purposes, I have two Codefluent entities: Customer and Order; where one related customer has many related orders.
On my ASP page, I have created the WebHierarchicalDataGrid, the WebHierarchicalDataSource, and two objectDataSources. For the WebHierarchicalDataSource I created two DataViews along with their DataRelations. The WebHierarchicalDataGrid's DataMember, Key, and DataKeyFields are all set correctly.
If the objectDataSources SelectMethods are set to the LoadAll methods of the CustomerCollection and the OrderCollection, the WebHierarchicalDataGrid displays as expected - that is the customer rows have nested order rows in the grid, and clicking on the +expansion icon displays the customer's order rows.
What I am trying to do is display the WebHierarchicalDataGrid for a single customer based on a user's input in a textbox on the webpage.
In the code behind I set the Customer's objectDataSource's SelectMethod to a method (LoadByCustomerID) defined in the Codefluent model which contains one paramameter (CustomerID) which I set to the value from the text box. I then call the Customer's objectDataSources Select method. This returns the desired Customer entity as expected.
From the returned Customer entity, I use data from a field (GUID) in the Customer entity to supply the SelectMethod (LoadOrdersByCustomerGUID) of the Order's objectDataSources. This too returns the expected OrderCollection of one or more related customer orders.
The results displayed in the WebHierarchicalDataGrid is only that of the parent row (the selected Customer). There is a +expansion icon displayed in the Customer row, but clicking on the +expansion icon does not display the retrieved order records for the selected customer.
How do I get the WebHierarchicalDataGrid to display the customer's related orders when the +expansion icon is clicked?
<ig:WebHierarchicalDataGrid ID="hdg_Customer" runat="server"
Height="600px" Width="95%"
AutoGenerateBands="False" AutoGenerateColumns="False"
DataMember="ods_Customer_DefaultView"
DataSourceID="hds_Customer"
Key="ods_Customer_DefaultView"
DataKeyFields="GUID"
Enabled="False" >
<Bands>
<ig:Band
AutoGenerateColumns="False"
DataMember="ods_Orders_DefaultView"
Key="ods_Orders_DefaultView"
DataKeyFields="GUID" >
<Columns>
<ig:BoundDataField DataFieldName="GUID" Key="GUID">
<Header Text="Order GUID">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="OrderDate" Key="OrderDate">
<Header Text="Order Date">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="TotalOrderAmount" Key="TotalOrderAmount">
<Header Text="Total Order Amount">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="relatedCustomerGUID" Key="relatedCustomerGUID">
<Header Text="related Customer GUID">
</Header>
</ig:BoundDataField>
</Columns>
</ig:Band>
</Bands>
<Columns>
<ig:BoundDataField DataFieldName="GUID" Key="GUID">
<Header Text="Customer GUID">
</Header>
</ig:BoundDataField>--%>
<ig:BoundDataField DataFieldName="CustomerID" Key="CustomerID">
<Header Text="Customer ID">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CustomerName" Key="CustomerName">
<Header Text="Customer Name">
</Header>
</ig:BoundDataField>
<ig:BoundDataField DataFieldName="CustomerState" Key="CustomerState">
<Header Text="Customer State">
</Header>
</ig:BoundDataField>
</Columns>
</ig:WebHierarchicalDataGrid>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
<ig:WebHierarchicalDataSource ID="hds_Customer" runat="server">
<DataViews>
<ig:DataView ID="ods_Customer_DefaultView"
DataMember="DefaultView"
DataSourceID="ods_Customer" />
<ig:DataView ID="ods_Orders_DefaultView"
DataMember="DefaultView"
DataSourceID="ods_Orders" />
</DataViews>
<DataRelations>
<ig:DataRelation
ChildColumns="relatedCustomerGUID"
ChildDataViewID="ods_Orders_DefaultView"
ParentColumns="GUID"
ParentDataViewID="ods_Customer_DefaultView" />
</DataRelations>
</ig:WebHierarchicalDataSource>
<asp:ObjectDataSource ID="ods_Orders" runat="server"
DataObjectTypeName="Accounts.Order"
OldValuesParameterFormatString="original_{0}"
SelectMethod="LoadAll"
TypeName="Accounts.OrderCollection" >
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ods_Customer" runat="server"
DataObjectTypeName="Accounts.Customer"
OldValuesParameterFormatString="original_{0}"
SelectMethod="LoadAll"
TypeName="Accounts.CustomerCollection" >
</asp:ObjectDataSource>
</asp:Content>
select Customer and related Orders (tried substituting this):
<asp:ObjectDataSource ID="ods_Orders" runat="server"
DataObjectTypeName="Accounts.Order"
OldValuesParameterFormatString="original_{0}"
SelectMethod="LoadByCustomerGUID"
TypeName="Accounts.OrderCollection" >
<SelectParameters>
<asp:Parameter DefaultValue="" Name="CustomerGUID" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ods_Customer" runat="server"
DataObjectTypeName="Accounts.Customer"
OldValuesParameterFormatString="original_{0}"
SelectMethod="LoadBySequence"
TypeName="Accounts.CustomerCollection" >
<SelectParameters>
<asp:Parameter DefaultValue="0" Name="Sequence" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
Code Behind:
protected void SelectID_Click(object sender, EventArgs e)
{
Accounts.Customer _customer = default(Accounts.Customer);
Accounts.CustomerCollection _customers = default(Accounts.CustomerCollection);
Accounts.OrderCollection _orders = default(Accounts.OrderCollection);
ods_Customer.SelectParameters("CustomerID").DefaultValue = textbox_CustomerID.Text;
_customers = ods_Customer.Select();
_customer = _customers(0);
ods_Orders.SelectMethod = "LoadByCustomerGUID";
ods_Orders.SelectParameters("CustomerGUID").DefaultValue = _customer.GUID.ToString;
_orders = ods_Orders.Select();
}