Skip to main content

DxPivotGridField.DataTemplate Property

Specifies the template used to display data cells.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor


public RenderFragment<object> DataTemplate { get; set; }

Property Value

Type Description

The template content.


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 following code snippet sets templates for the following Pivot Grid Fields:

  • Count - Uses a DataTemplate to apply bold formatting to all values.
  • Amount - Uses a DataTemplate to apply conditional formatting to values.
<DxPivotGrid Data="@GridData" ShowGrandTotals="@ShowGrandTotals" ShowFieldHeaders="@ShowFieldHeaders">
    <DxPivotGridField Field="@nameof(SaleInfo.Amount)" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Sum">
            <span class="@((decimal)context > 100000 ? "text-success" : "text-danger")">
                @string.Format("{0:c0}", context)
    <DxPivotGridField Field="@nameof(SaleInfo.OrderId)" Caption="Count" Area="PivotGridFieldArea.Data" SummaryType="PivotGridSummaryType.Count">
            <span class="font-weight-bold">@context</span>

Use the HeaderTemplate to customize content in row and column headers.

Run Demo: Pivot Grid - Pivot Grid Templates

See Also