vcl-cxcustomdata-0789d5f2.md
The procedural type for summary calculation events.
TcxSummaryEvent = procedure(ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments) of object;
| Name | Type | Description |
|---|---|---|
| ASender | TcxDataSummaryItems |
The summary item collection that raised the summary calculation event.
| | Arguments | TcxSummaryEventArguments |
Provides access to summary calculation arguments.
You can use Arguments.SummaryItem and Arguments.RecordIndex fields to identify the calculated summary item and its source record in the parent data controller.
| | OutArguments | TcxSummaryEventOutArguments |
Provides access to summary calculation results.
You can assign True to the OutArguments.Done field to exclude the currently processed record value from summary calculation.
|
A summary calculation event occurs for every processed record. You can handle this event to override or modify a predefined summary calculation algorithm.
The following code example excludes all Null Variant record values from summary calculation:
procedure TMyForm.cxGrid1DBTableView1DataControllerSummaryDefaultGroupSummaryItemsSummary(
ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments;
var OutArguments: TcxSummaryEventOutArguments);
begin
if (VarIsNull(OutArguments.Value)) then // If the currently processed value is Null Variant
OutArguments.Done := True; // Ignores the Null Variant record value
end;
void __fastcall TMyForm::cxGrid1DBTableView1DataControllerSummaryDefaultGroupSummaryItemsSummary(
TcxDataSummaryItems *ASender, TcxSummaryEventArguments &Arguments,
TcxSummaryEventOutArguments &OutArguments) {
if (VarIsNull(OutArguments.Value)) { // If the currently processed value is Null Variant
OutArguments.Done = true; // Ignores the Null Variant record value
}
}
All predefined summary calculation algorithms use record values of only one data item. The OnSummary event allows you to modify a predefined summary calculation algorithm in any manner. For example, you can use values of multiple data items in every iteration of the summary calculation process.
The code example below demonstrates an OnSummary event handler that modifies the predefined algorithm MAX. The event handler calculates the highest population density based on data-aware grid columns that display country areas ( DBTableView1Area ) and corresponding population values ( DBTableView1Population ):
procedure TMyForm.cxGrid1DBTableView1DataControllerSummaryDefaultGroupSummaryItemsSummary(
ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments;
var OutArguments: TcxSummaryEventOutArguments);
var
AArea, APopulation: Variant;
begin
// Obtain the area value for the currently processed record
AArea := ASender.DataController.Values[Arguments.RecordIndex, DBTableView1Area.Index];
// Obtain the population value for the currently processed record
APopulation := ASender.DataController.Values[Arguments.RecordIndex, DBTableView1Population.Index];
OutArguments.Value := APopulation/AArea; // Calculates the custom summary value (maximum population density)
end;
void __fastcall TMyForm::cxGrid1DBTableView1DataControllerSummaryDefaultGroupSummaryItemsSummary(
TcxDataSummaryItems *ASender, TcxSummaryEventArguments &Arguments,
TcxSummaryEventOutArguments &OutArguments) {
// Obtain the area value for the currently processed record
Variant AArea = ASender->DataController->Values[Arguments.RecordIndex][DBTableView1Area->Index];
// Obtain the population value for the currently processed record
Variant APopulation = ASender->DataController->Values[Arguments.RecordIndex][DBTableView1Area->Index];
OutArguments.Value = APopulation/AArea; // Calculates the custom summary value (maximum population density)
}
The following events reference the TcxSummaryEvent procedural type:
TcxDataSummaryItems.OnSummaryAllows you to customize summary calculation.TcxGridChartDataController.OnSummaryOccurs when calculating a specific summary value.TcxGridDBChartDataController.OnSummaryOccurs when calculating a specific summary value. See Also