Setting formatting on the entire column will try to format the calculation string containing Average & Sub-Average string formatting as well. We already demonstrate in the sample how to format the cells containing values, and leave the fixed, summary cells with the default formatting.
If you want to apply formatting you can change the code to
procedure TForm130.TMSFNCDataGrid1GetCellFormatting(Sender: TObject;
ACell: TTMSFNCDataGridCellCoord; AData: TTMSFNCDataGridCellValue;
var AFormatting: TTMSFNCDataGridDataFormatting;
var AConvertSettings: TFormatSettings; var ACanFormat: Boolean);
begin
if (ACell.Column = 9) and (TMSFNCDataGrid1.RowTypes[ACell.Row] = grtDefault) and (ACell.Row > TMSFNCDataGrid1.FixedRowCount - 1) then
begin
AFormatting.&Type := gdftFloat;
AConvertSettings.DecimalSeparator := '.';
AFormatting.Format := '#,##0.###';
end;
end;
If you want to change the formatting for the calculation, this can be done here:
TMSFNCDataGrid1.ColumnCalculations[9, 'Average Fare Price'] := [CreateGroupColumnCalculation(gcmAverage,
procedure(AColumn: Integer; ALevel: Integer; var AOptions: TTMSFNCDataGridDataColumnCalculationOptions)
begin
AOptions.CalculationFormatType := gcfFloat;
if ALevel = 1 then
AOptions.CalculationFormat := 'Sub-Average Fare Price: #,##0.###'
else
AOptions.CalculationFormat := 'Average Fare Price: #,##0.###';
end
)];
