Working with footer
Beside Column’s headers, you may show footer cell for each column. In footer you may place simple text, or you may show result of formula.
Footers are not visible by default. To show footers set ShowFooter
property of W3Grid to True
.
To access Column’s footer object, use Footer
property of Column. Header
and Footer
both share same ancestor and properties such as Caption
can be found in Footer too.
Example:
W3Grid1.Columns[2].Footer.Caption := 'Totals: ';
Set formula
Beside Capion property, Footer object include a new property named FormulaKind
(of W3FormulaKind
type). By setting this property you chose which kind of calculations (formula) will be done on this column. Result of formula will be displayed in footer, along with Caption
.
Following calculations are possible on column: Sum, Average, Count, Minimum and Maximum.
To start calculating simply call CalculateFooters
method of W3Grid.
Example:
// Insert and set your data first W3Grid1.Columns[2].Footer.FormulaKind := fkSum; W3Grid1.CalculateFooters;
If FormulaKind
is anything but fkNone
, column will be calculated and result will be displayed beside footer caption. Result will be also placed inside FormulaResult
(of Double type) property.
TextAfter property
There is one more property which may be very helpful – TextAfter
property which specifies text to be displayed beside result of formula. Usually this property contain currency sign, or some kind of measure unit.
Example:
W3Grid1.Column[2].Footer.FormulaKind := fkSum; W3Grid1.Column[2].Footer.Caption := 'Total: '; W3Grid1.Column[2].Footer.TextAfter := ' USD';
Sample output:
Total: 36643.43 USD