Skip to main content
A newer version of this page is available. .

Predefined Aggregate Functions

  • 4 minutes to read

When creating a summary item (an ASPxSummaryItem instance), you can define its aggregate function type via the ASPxSummaryItemBase.SummaryType property. ASPxGridView provides you with built-in implementation of the most popular aggregate functions such as Average, Count, Max, Min and Sum. Summaries of these predefined types are implemented so that they have a specific summary structure and can be localized and formatted with ease.

Summary Structure

By default, the display text representing a calculated summary consists of the summary label (that describes the applied aggregate function) and the summary display value (that is the calculated value with the applied formatting if any).

predefinedsummary-1.png

For each predefined aggregate function type, there are two default summary label representations: one is used when a summary is displayed within the associated column whose values it aggregates (specified via the ASPxSummaryItemBase.FieldName property), another is used when a summary is displayed within another column (specified via the ASPxSummaryItem.ShowInColumn or ASPxSummaryItem.ShowInGroupFooterColumn property).

PredefinedSummary-2.png

Summary Text Localization

The table below describes the predefined function types, and lists the corresponding resource strings used for localization and their default format patterns.

Summary Type Description Display in Column Resource String ID Default Format
Average Specifies that a column’s average value must be calculated. Calculated (FieldName) ASPxGridViewStringId.Summary_Average Avg={0}
    External (ShowInColumn, ShowInGroupFooterColumn) ASPxGridViewStringId.Summary_Average_OtherColumn Avg of {1} is {0}
Max Specifies that a column’s maximum value must be calculated. Calculated (FieldName) ASPxGridViewStringId.Summary_Max Max={0}
    External (ShowInColumn, ShowInGroupFooterColumn) ASPxGridViewStringId.Summary_Max_OtherColumn Max of {1} is {0}
Min Specifies that a column’s minimum value must be calculated. Calculated (FieldName) ASPxGridViewStringId.Summary_Min Min={0}
    External (ShowInColumn, ShowInGroupFooterColumn) ASPxGridViewStringId.Summary_Min_OtherColumn Min of {1} is {0}
Sum Specifies that the sum of a column’s values must be calculated. Calculated (FieldName) ASPxGridViewStringId.Summary_Sum Sum={0}
    External (ShowInColumn, ShowInGroupFooterColumn) ASPxGridViewStringId.Summary_Sum_OtherColumn Sum of {1} is {0}
Count Specifies that the number of records within a column must be calculated. Any ASPxGridViewStringId.Summary_Count Count={0}

The placeholders used in format patterns are:

  • {0} - contains the calculated summary value;
  • {1} - contains the name of the column by whose values the summary is calculated (this placeholder is used when the summary text is displayed within another column).

Note that the resource strings listed in the table above are intended to localize summary label texts, but not summary display values. These resource strings can be used when you localize your application through global resources, as it is described within the Localizing ASP.NET Controls via Global Resources (Obsolete from 11.2) topic.

Summary Formatting

ASPxGridView provides you with flexible summary display text customization means. You can use the following properties to provide a custom format for the summary value or even the entire summary text displayed by a summary item.

  • Column’s DisplayFormatString

    On the column level, you can define a display format for column values (via the EditPropertiesBase.DisplayFormatString property available through a column’s GridViewDataColumn.PropertiesEdit property), and it will apply to column summary values as well.

    Note

    The DisplayFormatString property’s setting is not in effect for a summary item if its ASPxSummaryItemBase.ValueDisplayFormat or ASPxSummaryItemBase.DisplayFormat property is specified.

  • Summary item’s ValueDisplayFormat

    On the summary item level, the ASPxSummaryItemBase.ValueDisplayFormat property allows you to additionally format the calculated summary value for display purposes. The summary value pattern, specified via ValueDisplayFormat, can include static text intermixed with a single format item (indexed placeholder) - {0} - that corresponds to the calculated summary value.

    Note

    The ValueDisplayFormat property’s setting is not in effect if the ASPxSummaryItemBase.DisplayFormat property is specified.

  • Summary item’s DisplayFormat

    On the summary item level, use the ASPxSummaryItemBase.DisplayFormat property to define a format string specifying the display format for the entire summary. The DisplayFormat property can accept static text intermixed with two format items (indexed placeholder) - {0} and {1}. {0} corresponds to the calculated summary value, and {1} corresponds to the caption of the column, the values of which the current summary aggregates.

    Note

    If the DisplayFormat property is defined for a summary item, localization via resource strings is not in effect for this summary.

Note that you can also use the ASPxGridView.SummaryDisplayText event to provide custom display text for summaries.