Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxPivotTableField.CellTemplate Property

Specifies a template for data cells that correspond to the current field.

Namespace: DevExpress.Blazor.PivotTable

Assembly: DevExpress.Blazor.PivotTable.v24.2.dll

NuGet Package: DevExpress.Blazor.PivotTable

#Declaration

#Property Value

Type Description
RenderFragment<PivotTableFieldCellTemplateContext>

The template content.

#Remarks

The Pivot Table component allows you to use different templates to customize appearance of its areas: headers, field values, data cells.

The DxPivotTable.FieldCellTemplate property specifies a common template for all data cells in the component. The DxPivotTableField.CellTemplate property overrides the common template for the data cells that correspond to the current field.

The following code specifies CellTemplate and ValueTemplate.

@rendermode InteractiveServer

<DxPivotTable Data="SalesData">
    <Fields>
        <DxPivotTableField Field="@nameof(SaleInfo.Region)"
                           Area="@PivotTableArea.Row"
                           AreaIndex="0" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Country)"
                           Area="@PivotTableArea.Row"
                           SortOrder="@PivotTableSortOrder.Descending"
                           AreaIndex="1" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateYear"
                           Area="@PivotTableArea.Column"
                           AreaIndex="0" 
                           Caption="Year" />
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Date)"
                           GroupInterval="@PivotTableGroupInterval.DateQuarter"
                           Area="@PivotTableArea.Column"
                           AreaIndex="1"
                           Caption="Quarter" >
            <ValueTemplate>
                <span>@($"Q{context.Text}")</span>
            </ValueTemplate>
        </DxPivotTableField>
        <DxPivotTableField Field="@nameof(Sales.SaleInfo.Amount)"
                      SortOrder="@PivotTableSortOrder.Ascending"
                      Area="@PivotTableArea.Data"
                      SummaryType="@PivotTableSummaryType.Sum">
            <CellTemplate>
                <span class="fw-bold">@context.Value</span>
            </CellTemplate>
        </DxPivotTableField>
    </Fields>
</DxPivotTable>

@code {
    IEnumerable<SaleInfo> SalesData;
    protected override async Task OnInitializedAsync() {
        SalesData = await Sales.GetSalesAsync();
    }
}

Pivot Table - Templates

Run Demo: Templates

#Implements

See Also