Customizing grid footer
Customizing grid footer
TDBGridEh
can display special row (footer) or rows at bottom part.
Use FooterRowCount
property to specify the number of footer rows in the grid. Use Footer or Footers
property of TColumnEh
object to specify information which needs to show in footer cells. The Footers
property is useful when you have more than one footer rows. Footers
are a collection of TColumnFooterEh
objects. Information from i-th element of collection will be shown in i-th row of footer. In footer cell, it is possible to show: Sum value for the specific field, records count, the value of a specific field or static text. Use Footer.ValueType
or Footers[i].ValueType
property to specify which type of value will be shown in the footer cell. If ValueType = fvtStaticText
, then you also need to set Value
property to specify text which will be shown. If ValueType = fvtFieldValue
, then you need to set property FieldName
to specify the field, value of which will be shown. To force grid to calculate total values you need to activate SumList
(Set DBGridEh.SumList.Active
to True
value). Set TColumnFooterEh.ValueType
to fvtSum
to show sum value of the column field in the footer cell, you can also specify Column.Footer.FieldName
to calculate total value of the other field. Set ValueType
to fvtCount
to force grid to display count of records in the footer cell.
Use the sub-properties of TDBGridEh.FooterParams
property to Customize the footer of the grid:
Color: TColor
FillStyle: TGridCellFillStyleEh
Font: TFont
ParentFont: Boolean
RowHeight: Integer
RowLines: Integer
HorzLineColor: TColor
HorzLines: Boolean
VertLineColor: TColor
VertLines: Boolean
The SumList property includes the following subproperties:
Active: Boolean
ExternalRecalc: Boolean
VirtualRecords: Boolean
DBGridEh events, related to the calculation of aggregate values in SumList'e:
OnSumListRecalcAll
The event is called when DBGridEh.SumList.ExternalRecalc = True
. In the event handler is necessary to calculate the aggregate amount for the items in the collection and fill DBGridEh.SumList.SumCollection
value DBGridEh.SumList.SumCollection[i].SumValue
.
OnSumListAfterRecalcAll
TColumnEh.Footer
and TSolumnEh.Footers[i]
elements have TColumnFooterEh
type and contain the following properties:
Alignment: TAlignment
Color: TColor
DisplayFormat: String
EndEllipsis: Boolean
FieldName: String
Font: TFont
ToolTips: Boolean
Value: String
property SumValue: Variant
ValueType: TFooterValueType
fvtNon
, fvtSum
, fvtAvg
, fvtCount
, fvtFieldValue
, fvtStaticText
, fvtMin
, fvtMax
WordWrap: Boolean
Use DBGridEh.OnGetFooterParams
event in order to control the parameters of the cell footer draw operation.
procedure TForm2.DBGridEh2GetFooterParams(Sender: TObject; DataCol,
Row: Integer; Column: TColumnEh; AFont: TFont; var Background: TColor;
var Alignment: TAlignment; State: TGridDrawState; var Text: string);
begin
end;
In the event you can change property values AFont
, Background
, Alignment
, Text
to change the text and text fortmat footer cell before rendering.
Use the following methods and properties when using the footer:
function TColumnEh.ColumnUsedFooter(Index: Integer): TColumnFooterEh;
Get a reference to the TColumnFooterEh
object, which contains the properties used to display the value in the footer cell. The Index
parameter must contain the index of the row in the grid footer section.
function TDBGridEh.GetFooterValue(Footer: TColumnFooterEh; Column: TColumnEh): String;
The method returns the footer value as a string for a specific column. The Footer
parameter specifies a TColumnFooterEh
object. The Column
parameter specifies the column for which the footer value should be obtained.