True DBGrid Show Column Totals

Posted by: sarosh.wadia on 17 October 2017, 2:33 am EST

    • Post Options:
    • Link

    Posted 17 October 2017, 2:33 am EST

    Hi!

    I am using the C1TrueDBGrid in a WinForms App (C1 WinForms 4.0) and want to display Totals for Columns in the grid. I have set the Aggregate to Count/Sum for each column as required and have also set the grids ColumnFooters to true.

    I can see the ColumnFooter Row but none of the Columns are showing their counts, sums etc.

    Thanks

  • Posted 17 October 2017, 4:00 pm EST

    Hello!

    Please refer to the ‘AggreGateFooter’ in the ComponentOne samples installed along with the product, at the given location on your machine:

    \Documents\ComponentOne Samples\WinForms\C1TrueDBGrid\CS\AggreGateFooter

    In case you need any further assistance, you can let me know.

    Regards,

    Meenakshi

  • Posted 18 October 2017, 1:51 am EST

    Hi!

    I went through the code in the “AggreGateFooter” solution and saw that the “BindingListChanged” event calls _calcFooter() which manually loops through all the rows in the grid to get the total and then stores that in the columns FooterText.

    The grid has a few thousand rows and users are adding/deleting, filtering this data all the time. Are you telling me that I have to manually recalculate (about 15 columns) all the column totals each time they add/edit/delete/filter the data?

    What’s the point of setting the Aggregate to Count/Sum for each column if I have to manually loop through all the grid rows and set the FooterText?

    Shouldn’t this be handled automatically by the grid once you set the Aggregate for a column?

    I’m hoping there is a better way than this or am I missing something!

    Thanks

  • Posted 22 October 2017, 10:06 pm EST

    Hi!

    Sorry to mention that there is no other way possible for doing this, at the moment. However, you can try something like this with C1FlexGrid also, if possible.

    C1FlexGrid provides Subtotal method that can show aggregates without looping through all rows. Kindly refer to the ‘Subtotals’ in ComponentOne samples, installed along with the product, at the given location on your machine:

    \Documents\ComponentOne Samples\WinForms\C1FlexGrid\CS\Subtotals

    Regards,

    Meenakshi

  • Posted 23 October 2017, 3:42 am EST

    Hi!

    I found a way to get the Column Totals using GroupedCoumns in the C1TrueDBGrid but Can I show this group total at the Bottom of the data instead of the the Top?

    something similar to the FlexGrid’s SubtotalPosition = SubtotalPositionEnum.BelowData

    Thanks

  • Posted 23 October 2017, 8:03 pm EST

    Hello!

    You can set GroupInfo.Position property of each column to ‘Footer’ value. Attached is a small sample for your reference.

    Regards,

    Meenakshi

    Prj_SummaryRowPosition.zip

  • Posted 25 October 2017, 6:24 am EST

    Hi!

    That worked!

    Thanks

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels