Format Summary Value
- 2 minutes to read
Summary text consists of a summary label that displays an aggregate function name and a summary’s calculated value.
Predefined Display Formats
The grid has the following predefined display formats for summaries:
- ‘Aggregate function’ = {0} - for summaries that are shown in the same column in which the values are calculated.
- ‘Aggregate function’ of {1} is {0} - for summaries that are shown in another column.
{0} - the calculated summary value, {1} - the column’s caption.
<TotalSummary>
<dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum" />
<dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum" ShowInColumn="ProductName" />
</TotalSummary>
Custom Display Formats
The grid allows you to format a summary’s calculated values and the entire summary text as follows.
Format Column Values and Summary Value in the Same Format
Use the DisplayFormatString property to define a display format for column values. This format applies to column summary values as well.
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="1">
<PropertiesTextEdit DisplayFormatString="c" />
</dx:GridViewDataTextColumn>
Result: Sum=$1,354,458.59
Format Summary Value
Specify the ValueDisplayFormat property to 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} - that corresponds to the calculated summary value.
<dx:ASPxSummaryItem FieldName="Total" SummaryType="Sum" ValueDisplayFormat="<b>{0:c0}</b>"/>
Result: Sum=$1,354,459
Format Summary Text
Specify the DisplayFormat property to format the entire summary text. The pattern can include 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.
<dx:ASPxSummaryItem FieldName="Amount" SummaryType="Sum" DisplayFormat="Total of {1}: {0:c2}"/>
Result: Total of Amount: $1,354,458.59
Limitations
- The DisplayFormatString property is not in effect for a summary item if its ValueDisplayFormat or DisplayFormat property is specified.
- The ValueDisplayFormat property is not in effect if the DisplayFormat property is specified.
- If you define the DisplayFormat property for a summary item, localization by resource strings is not in effect for this summary.