Back to Devexpress

Standard Formatting

wpf-8317-controls-and-libraries-pivot-grid-data-shaping-data-formatting-standard-formatting.md

latest3.0 KB
Original Source

Standard Formatting

  • Apr 01, 2021
  • 2 minutes to read

DevExpress controls use a standard formatting mechanism to format values as described in Microsoft documentation. The current document describes specific API related to formatting values displayed in the PivotGridControl.

The PivotGridControl 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:

xaml
<dxpg:PivotGridControl.Fields>
    <dxpg:PivotGridField Area="DataArea" FieldName="Extended_Price" CellFormat="c0"/>
    <dxpg:PivotGridField Area="RowArea" FieldName="OrderDate" GroupInterval="Date" ValueFormat="D"/>
    <dxpg:PivotGridField Area="ColumnArea" FieldName="Country"/>  
</dxpg:PivotGridControl.Fields>