This is a migrated thread and some comments may be shown as answers.

Accessing aggregate function results for each group item

1 Answer 184 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dmitriy
Top achievements
Rank 1
Dmitriy asked on 26 Jul 2016, 04:15 AM
Hi,

I have rows in the grid grouped by a field - Currency. I have a column (Amount) for which I define aggregate function Sum. Result of aggregate function is shown in the header of each group. All works great.

Now I want to show a summary of all Currencies and total Amounts for each of them at the bottom of the grid. For the sake of this example let’s say I have 100 rows in the grid and only two distinct values for Currency field: USD and RUB.

I want to have summary that will look like this:
Total USD -   1,234.00
Total RUB - 13,023.00

Using Grid.AggregateResults property only provides me with a total aggregate across all currencies:
Total – 14,257.00
with no break-down by groups.

How can I achieve this without grouping my data myself – RadGridControl already did this, I don’t want to recalculate the same values again?

Thank you,
Dmitriy

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 28 Jul 2016, 01:36 PM
Hi Dmitriy,

You can create Custom AggregateFunction that counts the sum of each separate currency. Please check the following demo in our WPF Demos application - GridView Custom Aggregate Function. I have created a sample project that implements the suggested behavior. Please review it and consider such approach at your end as well.

Please update me whether the information was useful. Of course, if you have any further questions or concerns, do not hesitate to contact us.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Dmitriy
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or