Is it possible to have a hierarchical RadGrid where the DetailTable is bound to a property from the Master's data object?
For example, my RadGrid (MasterTableView) is bound to an ObjectDataSource. The select method returns a collection of Customer objects. Each Customer object has a collection of Account objects (simple one-to-many relationship).
Obviously my MasterTableView displays the Customer columns and I'd like to simply display all the Accounts in a nested or detail-style table indented underneath.
Where I'm getting confused is whether or not the DetailTable (GridTableView) must use another datasource.
It seems inefficient to have to make additional trips to the database to lookup the accounts for each individual Customer when I already have everything I need.
I think I'm basically wanting to somehow bind my DetailTables (GridViewTable) DataSource to the Accounts property.. but the only option I see is to point it to a completely different DataSourceId.
This is a trimmed-down version of my RadGrid and what I'm basically trying to achieve. (I know the DataSource property shown on the GridTableView isn't valid - this is just me trying to show what I'd like to do.)
The Customer Object is basically
CustomerId (key)
FName
LName
Accounts (collection of Account objects)
Account object is basically:
AccountId (key)
CustomerId (foreign key)
Type
AcctNum
Any guidance would be appreciated.
Thanks-
Kenneth
For example, my RadGrid (MasterTableView) is bound to an ObjectDataSource. The select method returns a collection of Customer objects. Each Customer object has a collection of Account objects (simple one-to-many relationship).
Obviously my MasterTableView displays the Customer columns and I'd like to simply display all the Accounts in a nested or detail-style table indented underneath.
Where I'm getting confused is whether or not the DetailTable (GridTableView) must use another datasource.
It seems inefficient to have to make additional trips to the database to lookup the accounts for each individual Customer when I already have everything I need.
I think I'm basically wanting to somehow bind my DetailTables (GridViewTable) DataSource to the Accounts property.. but the only option I see is to point it to a completely different DataSourceId.
This is a trimmed-down version of my RadGrid and what I'm basically trying to achieve. (I know the DataSource property shown on the GridTableView isn't valid - this is just me trying to show what I'd like to do.)
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"objCustomers"
AutoGenerateColumns
=
"False"
>
<
MasterTableView
DataSourceID
=
"objCustomers"
DataKeyNames
=
"CustomerId"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"FName"
/>
<
telerik:GridBoundColumn
DataField
=
"LName"
/>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"AccountId"
DataSource='<% Eval(Accounts) %>' />
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"CustomerId"
MasterKeyField
=
"CustomerId"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Type"
/>
<
telerik:GridBoundColumn
DataField
=
"AcctNum"
/>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
The Customer Object is basically
CustomerId (key)
FName
LName
Accounts (collection of Account objects)
Account object is basically:
AccountId (key)
CustomerId (foreign key)
Type
AcctNum
Any guidance would be appreciated.
Thanks-
Kenneth