[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
   Getting Started
  [Expand]Grid View
  [Expand]Tree List
  [Expand]Card View
  [Expand]Reporting
  [Expand]Chart Control
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Expand]Data Shaping
   [Expand]Data Analysis
   [Expand]Data Formatting
   [Expand]Layout
   [Expand]Appearance
   [Expand]Export
   [Expand]Design-Time Features
   [Expand]UI Elements
   [Collapse]Examples
    [Expand]Binding to Data
    [Expand]Data Shaping
    [Expand]Data Analysis
    [Expand]Data Formatting
    [Expand]Layout
    [Collapse]Appearance
      How to: Provide Custom Cell Appearance
      How to: Customize Cell Appearance via Templates
    [Expand]Data Export
    [Expand]Miscellaneous
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Scheduler
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Gauges
  [Expand]Vertical Grid
  [Expand]Data Editors
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Controls
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[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

How to: Customize Cell Appearance via Templates

Show Me

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

This example shows a share of sold units quantity per salesperson. This report contains absolute and percent values, and their graphical representation.

The content of pivot grid cells is replaced via templates, as described below:

1. A class that implements the ITemplate interface is created.

2. An instance of this class is created and assigned to the ASPxPivotGrid.CellTemplate property.

The ASPxPivotGrid passes an PivotGridCellTemplateContainer object to the ITemplate.InstantiateIn method. The PivotGridCellTemplateContainer.Value and Text properties contain the current cell's value and display text, respectively.

When implementing the InstantiateIn method, a web control is created to be rendered instead of the cell's content. This control is added to the PivotGridCellTemplateContainer.Controls collection.

To render a simple text, a LiteralControl is added to the PivotGridCellTemplateContainer.Controls collection.

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