Calculation of totals (incorrect examples)

TeeGrid VCL / FMX for Embarcadero RAD Studio, Delphi, C++ Builder and Lazarus Free Pascal.
Post Reply
REH Outsourcing
Newbie
Newbie
Posts: 25
Joined: Tue Mar 13, 2018 12:00 am

Calculation of totals (incorrect examples)

Post by REH Outsourcing » Fri Oct 05, 2018 9:02 am

Delphi version: Seattle (Not tested in Tokyo)
TTeeGrid version: VCL & FMX Registered version-1.06
Multidevice Application (FMX)
Platform: WIN32

The examples contained in Tee.Grid.Totals are not compilable, they seem developed for older versions of TTeeGrid.
In both examples the compiler gives the following error [dcc32 Error] : E2034 Too many actual parameters

With the examples of www.steema.com/product/gridvcl the same thing happens.

This would be an example if it works correctly for me.

Code: Select all

  
    uses Tee.Grid.Totals, Tee.Grid.Data
     
    TeeGrid1.Totals := TColumnTotals.Create( TeeGrid1.Footer );
    TeeGrid1.Totals.Calculation.Add( TeeGrid1.Columns['kilograms'] , TColumnCalculation.Sum );

Greetings and thanks.

Marc
Site Admin
Site Admin
Posts: 1266
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Calculation of totals (incorrect examples)

Post by Marc » Thu Oct 11, 2018 8:50 am

Hello,

Thanks for the problem report.

At the moment this is what I see as working correctly, see https://github.com/Steema/TeeGrid/blob/ ... _Array.pas

Code: Select all

// Setup grid Footer bands
var tmp : TColumnTotals;

TeeGrid1.Footer.Clear;
tmp:=Totals(TeeGrid1.Footer);
calls:

Code: Select all

// Return a new Totals grid-band
function Totals(const ACollection:TCollection):TColumnTotals;
begin
  result:=TColumnTotals.Create(ACollection);

  result.Calculation.Add('Name',TColumnCalculation.Count);
  result.Calculation.Add('Children',TColumnCalculation.Sum);
  result.Calculation.Add('Height',TColumnCalculation.Average);

  result.Calculation.Add(result.Columns['Address'].Items['Number'],TColumnCalculation.Max);

  result.Format.Font.Style:=[fsBold];
end;
The syntax/overload you referenced also works ok in this demo.
ie.

Code: Select all

TeeGrid1.Totals.Calculation.Add( TeeGrid1.Columns['kilograms'] , TColumnCalculation.Sum );
or in this case for example:

Code: Select all

  tmp:=TColumnTotals.Create(TeeGrid1.Footer);
  tmp.Calculation.Add(TeeGrid1.Columns['Children'],TColumnCalculation.Sum);
The key to the difference seems to be the use of "tmp as TColumnTotals", rather than calling "TeeGrid1.Totals" (unfound by the compiler). I'll look around for examples; that may be old syntax as you suggest or simply an error where we have it included in documentation. We'll change examples we find for the new syntax.

Regards,
Marc
Steema Support

Post Reply