5

Got a grid with some numeric columns and it's need to implement for each column an aggregate (sum or count) and display it under the corresponding column.

I know that some suites (DevExpress or other) had already implemented "by default". But there is a way to implement that using default controls or JVCL?

Cœur
  • 37,241
  • 25
  • 195
  • 267
DreadAngel
  • 772
  • 11
  • 30
  • 2
    When you mentioned JVCL, there is the `TJvDBGridFooter`, what might actually be what you are looking for. It has the `OnCalculate` event published, however I don't know how about resizing of this control. Are you looking for a control that will be resized along with the grid columns ? – TLama May 07 '12 at 13:08

1 Answers1

5

Since you have mentioned JEDI VCL, try to take a look at the TJvDBGridFooter component. It is the status bar for the TJvDBGrid control.

  • you can modify the displayed text in the OnDisplayText event
  • you can calculate the aggregate fields in the OnCalculate event
  • you can follow the grid column scroll, resize or modify the appearence of the panels

Check the demo projects from JVCL's ..\examples\JvUltimDBGrid folder to see it in action.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • Could You tell me - how to perform an agregate sum for an field and display it into footer. That example does not fullfill my needs - I use an ClientDataset. – DreadAngel May 07 '12 at 22:18
  • So, did you found the way ? Basically, it's about [`aggregate fields`](http://edn.embarcadero.com/article/29272) in a dataset. Then you add columns in the `TJvDBGridFooter.Columns` collection, set them `FieldName` to those aggregate fields from the connected dataset, set the `DisplayMask` like `Σ %d` and in `TJvDBGridFooter.OnCalculate` event fill the `CalcValue` parameter with the value from the aggregate field. – TLama May 08 '12 at 10:46