DxPivotGridField.DataTemplate Property
Specifies the template used to display data cells.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public RenderFragment<object> DataTemplate { get; set; }
Property Value
Type | Description |
---|---|
RenderFragment<Object> | The template content. |
Remarks
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">
<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.
See Also