Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[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
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Collapse]Data Shaping
    [Expand]Aggregation
     Grouping
    [Expand]Sorting
    [Expand]Filtering
    [Collapse]Data Formatting
      Standard Formatting
      Custom Formatting
   [Expand]Data Analysis
   [Expand]Layout
   [Expand]Printing and Exporting
   [Expand]Appearance
   [Expand]MVVM Enhancements
   [Expand]Miscellaneous
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2232.

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?​​​​​​​