You add two footers.
The first is a general footer for the grid.
Code:
// Set footer DBGPiutang
DBGPiutang.FooterRowCount := 1;
DBGPiutang.SumList.Active := True;
DBGPiutang.Columns.Items[3].Footer.ValueType := fvtStaticText;
DBGPiutang.Columns.Items[3].Footer.Value := 'Total Faktur : ' + IntToStr(DataModule1.qryPiutang.RecordCount);
DBGPiutang.Columns.Items[3].Footer.Alignment := taCenter;
DBGPiutang.FooterParams.FillStyle := cfstThemedEh;
DBGPiutang.FooterFont.Style := [fsBold];
DBGPiutang.Columns.Items[6].Footer.ValueType := fvtStaticText;
DBGPiutang.Columns.Items[6].Footer.Value := 'Total Piutang :';
DBGPiutang.Columns.Items[6].Footer.Alignment := taCenter;
DBGPiutang.Columns.Items[7].Footer.ValueType := fvtSum;
DBGPiutang.Columns.Items[7].Footer.DisplayFormat := '###,##0';
The second is for grouping data. A grouping footer is created for each group and for the entire grid.
Code:
//Add footer row
FooterRow := DBGPiutang.DataGrouping.Footers.Add;
FooterRow.Visible := True;
//Assign Sum aggregate function for 'SisaFaktur' column
Column := DBGPiutang.FieldColumns['SisaFaktur'];
FooterItemIndex := FooterRow.ColumnItems.ItemIndexByColumn(Column);
FooterItem := FooterRow.ColumnItems[FooterItemIndex];
FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
if FooterItemIndex >= 0 then
begin
FooterItem := FooterRow.ColumnItems[FooterItemIndex];
FooterItem.ValueType := TGroupFooterValueTypeEh.gfvSumEh;
end;
Сhoose one of the footers that you need.