Skip to main content

Standard Formatting

  • 2 minutes to read

DevExpress controls use a standard formatting mechanism to format values as described in Microsoft documentation. Th document describes specific API related to formatting values displayed in the ASPxPivotGrid control.

ASPxPivotGrid formats displayed values using the application’s specified culture by default. For instance, the images below demonstrate the same Pivot Grid whose date-time and summary values are formatted as “en-US” or “de-DE”.

You can change default formatting settings for data cells, field values, totals and grand totals using the following properties:

Member Description
PivotGridFieldBase.CellFormat Provides access to the format settings applied to cells.
PivotGridFieldBase.GrandTotalCellFormat Provides access to the format settings applied to grand total values.
PivotGridFieldBase.TotalCellFormat Provides access to the format settings applied to total cells.
PivotGridFieldBase.TotalValueFormat Provides access to the format settings applied to the total header.
PivotGridFieldBase.ValueFormat Provides access to the format settings applied to field values.

Example: How to Format Cell Values

The following example shows how to format Order Date field values and summaries corresponding to the Extended Price field. Order Date field values are formatted using a long date pattern while Extended Price summaries are formatted as integer currency values.

The result of the code is shown below:

AspPivot_Formatting_Example

<dx:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" ClientIDMode="AutoID" DataSourceID="SqlDataSource1" Theme="DevEx">
    <Fields>
        <dx:PivotGridField ID="fieldExtendedPrice" Area="DataArea" FieldName="Extended_Price" 
            CellFormat-FormatType="Numeric" CellFormat-FormatString="c0">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldOrderDate" Area="RowArea" FieldName="OrderDate" GroupInterval="Date" 
            ValueFormat-FormatType="DateTime" ValueFormat-FormatString="D">
        </dx:PivotGridField>
        <dx:PivotGridField ID="fieldCountry" Area="ColumnArea" FieldName="Country">
        </dx:PivotGridField>
    </Fields>
</dx:ASPxPivotGrid>
See Also