Calculation of totals (incorrect examples)

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.

  
    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.

Hello,

Thanks for the problem report.

At the moment this is what I see as working correctly, see TeeGrid-VCL-FMX-Samples/demos/VirtualData/Array/Unit_Array.pas at master · Steema/TeeGrid-VCL-FMX-Samples · GitHub

// Setup grid Footer bands
var tmp : TColumnTotals;

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

calls:

// 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.

TeeGrid1.Totals.Calculation.Add( TeeGrid1.Columns['kilograms'] , TColumnCalculation.Sum );

or in this case for example:

  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