TcxSummaryEvent Type
The procedural type for summary calculation events.
Declaration
TcxSummaryEvent = procedure(ASender: TcxDataSummaryItems; Arguments: TcxSummaryEventArguments; var OutArguments: TcxSummaryEventOutArguments) of object;
Parameters
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 |
OutArguments | TcxSummaryEventOutArguments | Provides access to summary calculation results. You can assign |
Remarks
A summary calculation event occurs for every processed record. You can handle this event to override or modify a predefined summary calculation algorithm.
Code Examples
Exclude Null Values from Summary Calculation
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;
Custom Summary Calculation
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;
Direct TcxSummaryEvent Type References
The following events reference the TcxSummaryEvent
procedural type:
- TcxDataSummaryItems.OnSummary
- Allows you to customize summary calculation.
- TcxGridChartDataController.OnSummary
- Occurs when calculating a specific summary value.
- TcxGridDBChartDataController.OnSummary
- Occurs when calculating a specific summary value.