Back to Devexpress

Standard Formatting

aspnet-7273-components-pivot-grid-data-formatting-standard-formatting.md

latest3.5 KB
Original Source

Standard Formatting

  • Jun 21, 2024
  • 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”.

en-US culture

de-DE culture

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

MemberDescription
PivotGridFieldBase.CellFormatProvides access to the format settings applied to cells.
PivotGridFieldBase.GrandTotalCellFormatProvides access to the format settings applied to grand total values.
PivotGridFieldBase.TotalCellFormatProvides access to the format settings applied to total cells.
PivotGridFieldBase.TotalValueFormatProvides access to the format settings applied to the total header.
PivotGridFieldBase.ValueFormatProvides 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:

aspx
<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

How to: Set a Culture for an ASP.NET Web Page