Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Custom Summaries for XamDataGrid - how can we tell what level of grouping is being calculated?


We are currently in the process of evaluating the XamDataGrid for our organization, and so far it looks very good.

I had 2 questions about the Custom summary process:

1. Let's say, we group our grid by multiple columns. In our custom summary class, how do we know which group is being currently calculated? We may need to display different values, depending on the level (and the grouped by columns) of the grouped record being currently calculated.

2. Is there a way to short-circuit the summary calc process? For instance, in some of our grids, we use pre-calculated summaries, so there is no need to go through every record and aggregate the values.



  • 160
    Offline posted

    Hello Ravi,

    Attached you will find a sample application with custom summary. The grid contains Names, Ages and Balance fields and the custom summary for the person with highest balance, displayed at the bottom. If we group, for example, by Age 3 groups will be created. Each group its leader will be displayed and leader of all records would be displayed at the bottom of the grid. If you group by another field for each subgroup would be displayed the leader and so on until again at the bottom of the grid you could see the leader of all records.

    In regards to your first question:
    Aggregate method:

    public override void Aggregate(object dataValue, SummaryResult summaryResult, Record record)
                double myCellValue = double.Parse(dataValue.ToString());
                DataRecord myCurrentRecord = record as DataRecord;
                if (myCurrentRecord != null && myCellValue > _currentTopBalanceAmount)
                    _currentTopBalanceAmount = myCellValue;
                    _currentTopBalancePerson = myCurrentRecord.Cells["Name"].Value.ToString();

    You can get the GroupBy record of myCurrentRecord using it's ParentRecord property, which contains GroupByField property and there is the last field you grouped by. Other useful properties could be found here. 

    In regards to your second question:
    When you create a custom summary, you have to inherit from the abstract SummaryCalculator class. This means that there are several methods that should be implemented. One of them is the Aggregate method, which will be called once per field is being calculated per row, so after further researching I believe it's not possible to skip the Aggregate method sometimes. 
    Additional information about custom summaries could be found here.

    I hope this information was helpful for you. Let me know if I may be of any further assistance.

    Teodosia Hristodorova
    Associate Software Developer