Skip to main content

Predefined Aggregate Functions

  • 4 minutes to read

When you create a summary item (an ASPxSummaryItem instance), you can use the ASPxSummaryItemBase.SummaryType property to define an item’s aggregate function type. ASPxGridView includes built-in aggregate functions such as Average, Count, Max, Min, and Sum. The control implements summaries of these predefined types so that they have a specific summary structure that you can localize and format.

Summary Structure

The summary text consists of the summary label that displays the applied aggregate function and the summary value.

predefinedsummary-1.png

For each predefined aggregate function type, there are two default summary label representations: one displays a summary within the associated column whose values the control aggregates (the ASPxSummaryItemBase.FieldName property), another displays a summary within another column (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 a column. The control calculates the summary according to this column’s values. Use this placeholder when you display the summary text within another column.

Note that the resource strings listed in the table above are intended to localize summary label text, but not summary display values. You can use these resource strings when you localize your application through global resources, as described within the following topic: Localizing ASP.NET Controls via Global Resources (Obsolete from 11.2).

Summary Formatting

ASPxGridView allows you to customize summary display text. You can use the following properties to specify a custom format for the summary value and text.

  • A column’s DisplayFormatString

    At the column level, you can define a display format for column values (the EditPropertiesBase.DisplayFormatString property available through a column’s GridViewDataColumn.PropertiesEdit property), and this format applies 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.

  • A summary item’s ValueDisplayFormat

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

    Note

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

  • A summary item’s DisplayFormat

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

    Note

    If you define the DisplayFormat property for a summary item, localization by resource strings is not in effect for this summary.

You can also use the ASPxGridView.SummaryDisplayText event to specify custom text for summaries.