Skip to main content

Summaries

  • 3 minutes to read

The ExpressQuantumGrid provides a very useful feature called Summaries. It allows you to calculate totals against a group of records or all the records and represent the results in a convenient form.

You can create multiple summaries both at runtime via code and at design time using the Component Editor and Object Inspector.

Our grid control gives you the ability to calculate five built-in summaries:

  • Sum

  • Average of values

  • The number of records

  • Maximum value

  • Minimum value

But it is also possible to calculate more complex aggregate functions which combine the values of several columns. This can be implemented by handling grid events (OnSummary and OnAfterSummary). You are also able to exclude specific rows (containing NULL, for instance) and change the summary results on the fly.

There are two summary types available: footer and group summaries. A footer summary calculates its value by using all the records in a grid View. The footer summary result is displayed within the footer panel at the bottom of a grid View.

In tabular Views, group summaries are calculated when data is grouped by column(s). They are calculated for each data group created and displayed either within a group row or within the group’s footer. Only records contained within a group are used to evaluate these summary values.

In Chart Views, group summaries are calculated when series values are aggregated in the same categories using data groups (TcxGridChartDataGroup or TcxGridDBChartDataGroup). Group summaries are calculated for each category and displayed as aggregate values.

The View’s OptionsView.GroupFooters property determines the manner in which group footer panels are displayed. Group footer panels can be set to always be visible, visible only when a group is expanded or they can be completely hidden.

ExpressQuantumGrid allows you to calculate individual group summaries according to the current group column. The following screenshot displays data grouped by two columns: Product and Customer:

For the group identified by the Product grouping column, two summaries are calculated:

  • Last purchase date – the maximum value within the PurchaseDate column

  • Records – the number of records within the group

For the group identified by the Customer grouping column, two different summaries are calculated:

  • Payment Amount – the sum of the values in the PaymentAmount column

  • Quantity – the sum of the Quantity column

Calculating different summaries when grouping by specific columns is implemented by creating summary groups. A summary group links a proposed group column(s) with the group summaries to calculate.

For the above example, two summary groups must be created. The first one links the Product column with the two summaries (Last purchase date and Records). The second summary group links the Customer column with another two summaries (Payment Amount and Quantity).

Summaries can only reference records relating to a single View. Card Views do not support summaries.

The calculation of summaries is implemented within the data controller. The main task of the data controller is to connect to a data store (custom data source or dataset). However, it also encapsulates grouping and filtering operations on data and evaluates summaries. To access the summaries of a particular View, use the View’s DataController.Summary object. The most convenient way to calculate footer and group summaries is to specify a summary for a particular column using the column’s Summary property.

For more information, see the summary related topics in the Task Based Help section.

See Also