DxPivotGridField.DataTemplate Property

Specifies the template used to display data cells.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll


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>
See Also