Use Data Summaries

  • 3 min to read

ASPxGridView allows you to display a summary, i.e., brief information about groups of rows or individual data columns. For example, you can display the number of records or the maximum value.

ASPxGridView supports two types of summaries:

  • Total Summary

    A total summary represents the value of an aggregate function calculated over all the rows within ASPxGridView and are displayed within the footer.

  • Group Summary

    A group summary represents the value of an aggregate function calculated over all rows within a group and displayed in the group row or group footer.

cdSummaryOverview

  • Custom Summary

    A custom summary allows you to calculate summaries against records that meet specific criteria and use multiple data fields in calculations.

Summaries (group and total) are represented by ASPxSummaryItem objects. To work properly, the following two summary item properties must be specified.


<dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum"/>

The summary item above summarizes the 'Total' field values within a group and displays the sum in the group row.

The ASPxSummaryItem object provides two properties allowing you to determine the location to display the summary.

Note

In server mode, a summary cannot be calculated for unbound columns in which values are calculated via events (see ASPxGridView.CustomUnboundColumnData). Only columns with unbound expressions (see GridViewDataColumn.UnboundExpression) support summary calculation.

Example

The code sample below demonstrates how you can specify group and total summaries. To specify the group summary items location, the ASPxSummaryItem.ShowInColumn and ASPxSummaryItem.ShowInGroupFooterColumn properties are used.

Note that summary item four is not displayed because the 'OrderDate' column, where the item should be displayed, does not exist (the grid is grouped by the 'OrderDate' field). Summary item five is not displayed because the 'Total' group row, where the item should be displayed, does not exist (the grid is not grouped by the 'Total' field)

The image below shows the result.

SummaryItem

<dx:ASPxGridView ID="grid" ...>
     ...
     <TotalSummary>
          <dx:ASPxSummaryItem FieldName="Total" SummaryType="Min" />
          <dx:ASPxSummaryItem FieldName="Total" SummaryType="Max" />
          <dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum" />
     </TotalSummary>

     <GroupSummary>
          <%-- Group Summary Item 1 --%>
          <dx:ASPxSummaryItem FieldName="Country" ShowInColumn="Country" SummaryType="Count" />
          <%-- Group Summary Item 2 --%>
          <dx:ASPxSummaryItem FieldName="Quantity" ShowInGroupFooterColumn="UnitPrice" SummaryType="Sum" />
          <%-- Group Summary Item 3 --%>
          <dx:ASPxSummaryItem FieldName="Total" ShowInColumn="ProductName" ShowInGroupFooterColumn="Quantity" SummaryType="Sum" />
          <%-- Group Summary Item 4 --%>
          <dx:ASPxSummaryItem FieldName="Quantity" SummaryType="Sum" ShowInGroupFooterColumn="OrderDate" />
          <%-- Group Summary Item 5 --%>
          <dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum" ShowInColumn="Total" />
     </GroupSummary>
     <Settings ShowGroupPanel="True" ShowFooter="True" ShowGroupFooter="VisibleIfExpanded"></Settings>
</dx:ASPxGridView>

Concepts

Member Table

Task-Based Help