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
480
Simple Subtotaling and Grand totaling of Grouped data
posted

I've often grouped data, but now I need subtotals at the grouped level - which I've never done. In addition, some of the fields are calculated (percent), whereas others are just summed up for the rows in the group.

I figure that there's either a way to 1) insert a summary row (or have it inserted as part of the grouping function), and then specify sum as the operation for most of the columns, and then do percentage operations against others for the percentage columns (which would mean an operation against two other columns to calculate the percent).

or 2) I figure you're going to tell me to iterate through all rows within the group (which I don't know how to do - I've only iterated an entire ungrouped grid, I don't know about trapping the group break etc.), and then add the values up into variables, then insert the row with these calculated variables into the grid at each group break (which I don't know how to do either), as well as then adding a grand total line.

I am hoping that the grid has some abilities that will let me do something similar to scenario (1) - where it'll keep track of all of these numbers for me (and let me specify sum, avg, etc. as operations to perform) and it can automatically break and subtotal at the group breaks. But if not, I'll iterate, sum, calculate, and add lines - whatever works.

What's the easiest way (in VB.NET) to accomplish this?

Thanks!

Parents
No Data
Reply
  • 23930
    Offline posted

    Hi,

    Thank you for contacting Infragistics Developer Support.

    What you could do in order to calculate the percentage summaries is to use the UltraCalcManager. This component lets you to calculate complicated formulas for your summaries while you only need to specify the formula that the UltraCalcManager should use. For more information on custom formulas please visit this link:

    http://help.infragistics.com/Doc/WinForms/2014.1/CLR4.0/?page=WinCalcManager_Formula_and_Reference_Guide.html

    As for how to insert the summaries, if you want them only when the data is grouped you could use the InitializeRowsCollection event of the grid and check if the grid has GroupByRows. Otherwise you could use the InitialzeLayout event. To add the summaries themselves you could use code like:

    UltraGrid1.DisplayLayout.Bands(0).Summaries.Add()

    I have attached a sample in VB.Net, which demonstrates my suggestions.

    Please let me know if you have any additional questions.

    WG_GroupedSummaries.zip
Children