Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 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

    DxPivotTable.FieldHeaderTemplate Property

    Specifies a common template to display field captions in the header area.

    Namespace: DevExpress.Blazor.PivotTable

    Assembly: DevExpress.Blazor.PivotTable.v25.1.dll

    NuGet Package: DevExpress.Blazor.PivotTable

    #Declaration

    #Property Value

    Type Description
    RenderFragment<PivotTableFieldHeaderTemplateContext>

    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.

    Use the FieldHeaderTemplate property to specify a common template for all field captions in the header area. To override a template for an individual field’s header, use the DxPivotTableField.HeaderTemplate property.

    The following code specifies FieldHeaderTemplate, FieldValueTemplate, and FieldCellTemplate.

    @rendermode InteractiveServer
    
    <DxPivotTable Data="SalesData"
                  style="height:440px">
        <Fields>
            <DxPivotTableField Field="@nameof(Sales.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" />
            <DxPivotTableField Field="@nameof(Sales.SaleInfo.Amount)"
                               SortOrder="@PivotTableSortOrder.Ascending"
                               Area="@PivotTableArea.Data"
                               SummaryType="@PivotTableSummaryType.Sum" />
        </Fields>
        <FieldHeaderTemplate>
            <span style="color:red">@context.Text </span>
        </FieldHeaderTemplate>
        <FieldValueTemplate>
            <span style="font-style: italic">@context.Value</span>
        </FieldValueTemplate>
        <FieldCellTemplate>
            <span style="font-weight: 300">@context.Value</span>
        </FieldCellTemplate>
    </DxPivotTable>
    
    @code {
        IEnumerable<Sales.SaleInfo> SalesData;
        protected override async Task OnInitializedAsync() {
            SalesData = await Sales.GetSalesAsync();
        }
    }
    

    Pivot Table - Templates

    Run Demo: Templates

    See Also