Skip to main content
A newer version of this page is available. .

DxGrid.ColumnHeaderCaptionTemplate Property

Specifies a common template used to display captions of all column headers in the Grid.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<GridColumnHeaderCaptionTemplateContext> ColumnHeaderCaptionTemplate { get; set; }

Property Value

Type Description
RenderFragment<GridColumnHeaderCaptionTemplateContext>

The template for all column headers.

Remarks

The ColumnHeaderCaptionTemplate allows you to customize captions of all column headers in the Grid. To define a template for individual column headers, use the DxGridColumn.HeaderCaptionTemplate.

The ColumnHeaderCaptionTemplate accepts a GridColumnHeaderCaptionTemplateContext object as the context parameter. You can use parameter members to get the current Caption, and the Column or DataColumn object. You can also access the Grid object and use its members to obtain additional information about the Grid.

The following example shows the tooltip when a user hovers the mouse pointer over any column caption:

@using Microsoft.EntityFrameworkCore
@inject IDbContextFactory<NorthwindContext> NorthwindContextFactory
@implements IDisposable

<DxGrid Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="Title" />
        <DxGridDataColumn FieldName="BirthDate" />
        <DxGridDataColumn FieldName="HireDate" />
    </Columns>
    <ColumnHeaderCaptionTemplate>
        <span title="Click the header to sort data by this column. Drag and drop the header to change the column's position">
            @context.Caption</span>
    </ColumnHeaderCaptionTemplate>
</DxGrid>

@code {
    IEnumerable<Employee> Data { get; set; }
    NorthwindContext Northwind { get; set; }
    Employee CurrentEmployee { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        Data = Northwind.Employees
            .ToList();
    }

    public void Dispose() {
        Northwind?.Dispose();
    }
}

Blazor Grid Column Header Caption Template

Run Demo: Grid - Column Templates

For more information about templates in the Grid component, refer to the following topic: Templates in Blazor Grid.

See Also