Hi,
I have a 3 level Radgrid with a footer row in the second level. The second level TableView has a column called 'Price' and the footer row displays the sum of the 'Price' column. The MasterTableView has a column called 'ItemTotalPrice'. Initially when there are no rows in the second level the 'ItemTotalPrice' column shows '0'. I would like to access the value of the footer in the second level and update the 'ItemTotalPrice' column of the corresponding parent row, whenever a new row is inserted into the second level.
Any help is greatly appreciated.
Thanks
Meera
I have a 3 level Radgrid with a footer row in the second level. The second level TableView has a column called 'Price' and the footer row displays the sum of the 'Price' column. The MasterTableView has a column called 'ItemTotalPrice'. Initially when there are no rows in the second level the 'ItemTotalPrice' column shows '0'. I would like to access the value of the footer in the second level and update the 'ItemTotalPrice' column of the corresponding parent row, whenever a new row is inserted into the second level.
Any help is greatly appreciated.
Thanks
Meera
4 Answers, 1 is accepted
0
Jayesh Goyani
Top achievements
Rank 2
answered on 23 Jun 2012, 04:31 PM
Hello Meera,
Please check below code snippet.
Thanks,
Jayesh Goyani
Please check below code snippet.
<
MasterTableView
DataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Name"
DataField
=
"Name"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ID"
DataField
=
"ID"
UniqueName
=
"ID"
Aggregate
=
"Sum"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"Name1"
DataField
=
"Name1"
UniqueName
=
"Name1"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ID1"
DataField
=
"ID1"
UniqueName
=
"ID1"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
protected
void
RadGrid1_InsertCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item
as
GridEditableItem;
// perform your insert oeration
GridFooterItem fi = item.OwnerTableView.ParentItem.OwnerTableView.GetItems(GridItemType.Footer)[0]
as
GridFooterItem;
fi[
"ID"
].Text =
"your new Text comes here"
;
}
Thanks,
Jayesh Goyani
0
Meera
Top achievements
Rank 1
answered on 25 Jun 2012, 05:03 AM
Hi Jayesh,
Thanks for the reply.
In your code sample the footer is placed in the parent table, in my case the footer is in the detail table. Please see code sample below.
When I insert / edit values to the details table the Price column is summed up correctly and displayed in the footer. I would like this value to be updated in the 'ItemTotalPrice' column of the parent table. Please let me know if you have any suggestions.
Thanks
Meera
Thanks for the reply.
In your code sample the footer is placed in the parent table, in my case the footer is in the detail table. Please see code sample below.
<
MasterTableView
DataKeyNames
=
"ID"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"ID"
DataField
=
"ID"
UniqueName
=
"ID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Name"
DataField
=
"Name"
UniqueName
=
"Name"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ItemTotalPrice"
DataField
=
"ItemTotalPrice"
UniqueName
=
"ItemTotalPrice"
ReadOnly
=
"true"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
DetailTables
>
<
telerik:GridTableView
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"ID1"
DataField
=
"ID1"
UniqueName
=
"ID1"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Name1"
DataField
=
"Name1"
UniqueName
=
"Name1"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"Price"
DataField
=
"Price"
UniqueName
=
"Price"
Aggregate
=
"Sum"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
When I insert / edit values to the details table the Price column is summed up correctly and displayed in the footer. I would like this value to be updated in the 'ItemTotalPrice' column of the parent table. Please let me know if you have any suggestions.
Thanks
Meera
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 25 Jun 2012, 07:01 AM
Hello Meera,
Thanks,
Jayesh Goyani
protected
void
RadGrid1_InsertCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = e.Item
as
GridEditableItem;
// perform your insert oeration
GridDataItem fi = item.OwnerTableView.ParentItem
as
GridDataItem;
fi[
"ID"
].Text =
"My Text"
;
}
Thanks,
Jayesh Goyani
0
Meera
Top achievements
Rank 1
answered on 26 Jun 2012, 05:14 AM
Hi Jayesh,
Thank you for your prompt response
I used the code sample you provided for accessing the ItemTotalPrice in the parent table. I was not able to access the footer, but instead I could sum up the rows of the detail table (which in fact is footer value) and assign it to the parent field.
Your answer helped to solve the problem
Regards
Meera
Thank you for your prompt response
I used the code sample you provided for accessing the ItemTotalPrice in the parent table. I was not able to access the footer, but instead I could sum up the rows of the detail table (which in fact is footer value) and assign it to the parent field.
Your answer helped to solve the problem
Regards
Meera