Accessing aggregate function results for each group item

2 posts, 0 answers
  1. Dmitriy
    Dmitriy avatar
    3 posts
    Member since:
    May 2012

    Posted 25 Jul Link to this post


    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,
  2. Stefan Nenchev
    Stefan Nenchev avatar
    240 posts

    Posted 28 Jul Link to this post

    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.

    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.
  3. DevCraft banner
Back to Top