Hi,
I need to calculate a custom aggregate value in a GridTableView based on the value of other 2 aggregate values (Sum).
GridTableView rise the OnCustomAggregate event for this column but I don't know how to get the aggregate values of other columns.
I need to calculate a value like this: (1 - (TotalCost / TotalPrice)) in the custom aggregate column.
TotalCost and TotalPrice are Sum aggregate values of other columns.
Any idea?
Regards
Jose
I need to calculate a custom aggregate value in a GridTableView based on the value of other 2 aggregate values (Sum).
GridTableView rise the OnCustomAggregate event for this column but I don't know how to get the aggregate values of other columns.
I need to calculate a value like this: (1 - (TotalCost / TotalPrice)) in the custom aggregate column.
TotalCost and TotalPrice are Sum aggregate values of other columns.
Any idea?
Regards
Jose
4 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Nov 2010, 06:43 AM
Hello Jose,
The following code snippet shows how to access the footer value for other columns in OnCustomAggregare event.
C#:
Thanks,
Princy.
The following code snippet shows how to access the footer value for other columns in OnCustomAggregare event.
C#:
protected
void
RadGrid1_CustomAggregate(
object
sender, GridCustomAggregateEventArgs e)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
string
footer=footerItem[
"TotalCost"
].Text
// accessing footer value using ColumnUniueName
}
Thanks,
Princy.
0
Jose
Top achievements
Rank 2
answered on 25 Nov 2010, 08:20 PM
Hi Princy,
Thank you very much for your help.
It's works very nice.
Regards
Jose
Thank you very much for your help.
It's works very nice.
Regards
Jose
0
Jose
Top achievements
Rank 2
answered on 25 Nov 2010, 08:36 PM
(Edited...: solved with a simple if --> if (e.Item is GridFooterItem))
Hi Princy,
I'm having a side effect with the custom aggregate.
When I group the child grid I'm receiving the next error:
Unable to cast object of type 'Telerik.Web.UI.GridGroupFooterItem' to type 'Telerik.Web.UI.GridFooterItem'.
This is the code:
Hi Princy,
I'm having a side effect with the custom aggregate.
When I group the child grid I'm receiving the next error:
Unable to cast object of type 'Telerik.Web.UI.GridGroupFooterItem' to type 'Telerik.Web.UI.GridFooterItem'.
This is the code:
protected
void
ListGrid_CustomAggregate(
object
sender, GridCustomAggregateEventArgs e)
{
GridFooterItem footerItem = (GridFooterItem)e.Item;
decimal
totalCost = Decimal.Parse(footerItem[
"TotalCost"
].Text, NumberStyles.Any);
decimal
totalPrice = Decimal.Parse(footerItem[
"TotalPrice"
].Text, NumberStyles.Any);
if
(totalPrice > 0)
e.Result = 1 - (totalCost / totalPrice);
else
e.Result = 0;
}
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2010, 06:28 AM
Hello Jose,
Since you have enabled Grouping, make the following changes in the above code to eliminate the error
.
C#:
Thanks,
Princy.
Since you have enabled Grouping, make the following changes in the above code to eliminate the error
.
C#:
protected
void
RadGrid1_CustomAggregate(
object
sender, GridCustomAggregateEventArgs e)
{
if
(e.Item
is
GridGroupFooterItem)
{
GridGroupFooterItem footerItem = (GridGroupFooterItem)e.Item;
string
id = footerItem[
"TotalCost"
].Text;
}
}
Thanks,
Princy.