blazor-devexpress-dot-blazor-dot-dxpivotgridfield-c36a8cc8.md
Specifies the template used to display data cells.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public RenderFragment<object> DataTemplate { get; set; }
| Type | Description |
|---|---|
| RenderFragment<Object> |
The template content.
|
Important
The Pivot Grid was moved to maintenance support mode. No new features/capabilities will be added to this component. We recommend that you migrate to the Pivot Table component.
The DxPivotGrid component allows you to use native Razor markup to define custom templates for its elements. Use the template’s context parameter to get the field value.
The code snippet below sets templates for the following Pivot Grid Fields:
<DxPivotGrid Data="@GridData" ShowGrandTotals="@ShowGrandTotals" ShowFieldHeaders="@ShowFieldHeaders">
<DxPivotGridField Field="@nameof(SaleInfo.Amount)" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Sum">
<DataTemplate>
<span class="@((decimal)context > 100000 ? "text-success" : "text-danger")">
@string.Format("{0:c0}", context)
</span>
</DataTemplate>
</DxPivotGridField>
<DxPivotGridField Field="@nameof(SaleInfo.OrderId)" Caption="Count" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Count">
<DataTemplate>
<span class="font-weight-bold">@context</span>
</DataTemplate>
</DxPivotGridField>
</DxPivotGrid>
Use the HeaderTemplate to customize content in row and column headers.
Run Demo: Pivot Grid - Pivot Grid Templates
See Also