[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand].NET Core 3 Support
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Collapse]Data Shaping
    [Collapse]Data Formatting
      Standard Formatting
      Custom Formatting
   [Expand]Data Analysis
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]MVVM Enhancements
   [Expand]UI Elements
   [Expand]End-User Capabilities
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Custom Formatting

The Pivot Grid control allows you to format the display text of its summary cells, field values, total and grand total headers according to a custom formatting rule.

Expanded Formatting Data Cells

The PivotGridControl allows custom text to be displayed within individual data cells. To do this, handle the PivotGridControl.CustomCellDisplayText event. This event is fired for each cell in bound and unbound fields.

Each data cell displays a summary value calculated against a Data Field. This data field is returned by the event parameter's PivotCellBaseEventArgs.DataField property. The cell's current value is returned by the event parameter's PivotCellBaseEventArgs.Value property.

To change the cell's display text, use the PivotCellDisplayTextEventArgs.DisplayText property. Initially, this property contains the text currently displayed within a cell. To provide a custom text, assign it to the PivotCellDisplayTextEventArgs.DisplayText property.

Expanded Formatting Column and Row Headers

The PivotGridControl allows you to customize the text displayed within column or row headers (field values, total and grand total headers etc.). To do this, handle the PivotGridControl.FieldValueDisplayText event. The current field value is obtained using the event parameter's PivotFieldDisplayTextEventArgs.Value property (if the event is fired for a grand total header or data field header, the PivotFieldDisplayTextEventArgs.Value property returns null). The custom display text should be assigned to the PivotFieldDisplayTextEventArgs.DisplayText property.

If the PivotGridControl.FieldValueDisplayText event is raised for a field value or total header, the PivotFieldEventArgs.Field property identifies the corresponding column field or row field. If this event is raised for a data field header, the PivotFieldEventArgs.Field property identifies the corresponding data field. If the event is raised for a grand total header, the PivotFieldEventArgs.Field property returns null. To get the type of the processed header, use the PivotFieldValueEventArgs.ValueType property.

The PivotGridControl.FieldValueDisplayText event is also raised for items in the filter dropdown. In this instance, the event parameter's PivotFieldDisplayTextEventArgs.IsPopulatingFilterDropdown property is set to true. The PivotFieldEventArgs.Field parameter returns the column, row or filter field whose dropdown has been invoked.

Expanded Example: How to Display Custom Text within Data Cells

The following example shows how to provide custom text for the PivotGridControl's cells by handling the PivotGridControl.CustomCellDisplayText event.In this example, if a grand total value is less than 50 000, 'Low' is displayed instead. If the value exceeds 100 000, 'High' is displayed; otherwise, 'Middle'.

Is this topic helpful?​​​​​​​