DxDataGrid<T>.HeaderTemplate Property

Specifies a template for a Data Grid’s header.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll


public RenderFragment HeaderTemplate { get; set; }

Property Value

Type Description

A template for a Data Grid’s header.


Use the HeaderTemplate property to customize the Data Grid’s header. For example, you can use this template to add a toolbar to a Data Grid component:

  1. Add the HeaderTemplate to the Data Grid’s markup.
  2. Add buttons (DxToolbarItem objects) to the Toolbar component in this template. Each button can display an icon, text, or both.
  3. Use the Columns property to add grid columns.
<DxDataGrid Data="@Data">
        <DxToolbar ItemRenderStyleMode="ToolbarRenderStyleMode.Plain" ItemSize="ToolbarItemSize.Small">
            <DxToolbarItem Text="New" BeginGroup="true" IconCssClass="grid-toolbar-new" />
            <DxToolbarItem Text="Edit" IconCssClass="grid-toolbar-edit" />
            <DxToolbarItem Text="Delete" IconCssClass="grid-toolbar-delete" />
            <DxToolbarItem Text="Show Filter Row" BeginGroup="true" GroupName="GroupName" />
            <DxToolbarItem Text="Documentation" 
                           target="_blank" />
        <DxDataGridColumn Field="@nameof(Order.Product)" />
        <DxDataGridDateEditColumn Field="@nameof(Order.OrderDate)" />
        <DxDataGridSpinEditColumn Field="@nameof(Order.UnitPrice)" />
        <DxDataGridSpinEditColumn Field="@nameof(Order.UnitsInOrder)" />
        <DxDataGridComboBoxColumn Field="@nameof(Order.OrderStatus)" Data="@DataStatus" />

DataGrid Toolbar

You can also use the HeaderTemplate property to display the Column Chooser in the Data Grid’s toolbar. For more information, refer to the Column Chooser’s documentation.

Run Demo: Data Grid - Toolbar

See Also