# Templates

The Kendo UI PivotGridV2 provides the built-in functionality to change the appearance of the rendered data by using \[templates]\(% slug overview_kendoui_templatescomponent %).

For a live example, visit the [PivotGridV2 Templates](https://demos.telerik.com/kendo-ui/pivotgridv2/templates) demo.

## Template Configurations

The PivotGridV2 offers three template configurations:

* [`dataCellTemplate`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/pivotgridv2/configuration/datacelltemplate)—Changes the appearance of each data cell.
* [`columnHeaderTemplate`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/pivotgridv2/configuration/columnheadertemplate)—Changes the appearance of each column header.
* [`rowHeaderTemplate`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/pivotgridv2/configuration/rowheadertemplate)—Changes the appearance of each row header.

The following example demonstrates how to set-up a `dataCellTemplate`:

```
<script id="dataCellTemplate" type="text/x-kendo-tmpl">
    # if (!dataItem) { #
         <em>N/A</em> 
     # } else { #
         <b><span style='color: green;'>#: dataItem.fmtValue #</span></b> 
     # } #
</script>

$("#pivotgrid").kendoPivotGridV2({
    dataCellTemplate: $("#dataCellTemplate").html()
});
```

The following example demonstrates how to set-up both a `columnHeaderTemplate` and a `rowHeaderTemplate` at once:

```
<script id="headerTemplate" type="text/x-kendo-tmpl">
    <b>#: member.caption #</b> 
</script>

$("#pivotgrid").kendoPivotGridV2({
    columnHeaderTemplate: $("#headerTemplate").html(),
    rowHeaderTemplate: $("#headerTemplate").html()
});
```

## Templates and Excel Export

The templates change only the rendered content of the PivotGridV2. During the [Excel export](https://www.telerik.com/kendo-jquery-ui/documentation/controls/pivotgridv2/export/excel-export), the PivotGridV2 exports the cell values and does not apply the `dataCellTemplate`, the `columnHeaderTemplate`, or the `rowHeaderTemplate`. To export the content that a template displays, modify the workbook in the [`excelExport`](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/pivotgridv2/events/excelexport) event.

When the PivotGridV2 is bound to flat data, the `dataItem` of the `dataCellTemplate` contains the aggregated result of the cell and not the source records. For an example that displays and exports a value from another field of the source records, refer to the [Displaying and Exporting a Source Field Value in PivotGridV2 Data Cells](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/pivotgridv2-raw-field-display-and-excel) article.

## See Also

* [PivotGridV2 Templates (Demo)](https://demos.telerik.com/kendo-ui/pivotgridv2/templates)
* [Excel Export in the PivotGridV2](https://www.telerik.com/kendo-jquery-ui/documentation/controls/pivotgridv2/export/excel-export)
* [PivotGridV2 JavaScript API Reference](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/pivotgridv2)
