Skip to main content

DxDataGrid<T>.RowPreviewTemplate Property

Specifies a template used to display row preview sections.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v22.1.dll

Declaration

[Parameter]
public RenderFragment<DataRowInfo<T>> RowPreviewTemplate { get; set; }

Property Value

Type Description
RenderFragment<DataRowInfo<T>>

The template content for an object of the DataRowInfo<T> type that stores information about the row (index and the corresponding data item). T is the data item type.

Remarks

Important

The Data Grid was moved to maintenance support mode. No new features/capabilities will be added to this component. We recommend that you migrate to the Grid component.

Use the RowPreviewTemplate property to show preview sections under each data row across all columns. These sections can display any content, such as tables, images, values from data source fields, custom text, etc.

The template’s Context parameter has the following properties:

  • RowIndex - Returns a zero-based row index.
  • DataItem - Returns a data item that corresponds to the row.

When you define the row preview template, use the Columns property to add Data Grid columns.

The following example demonstrates how to display preview sections with employee images and multi-line notes.

<DxDataGrid Data="@DataSource">
    <Columns>
        <DxDataGridColumn Field="@nameof(Employee.FirstName)" SortOrder="DataGridColumnSortOrder.Ascending"></DxDataGridColumn>
        <DxDataGridColumn Field="@nameof(Employee.LastName)"></DxDataGridColumn>
        <DxDataGridColumn Field="@nameof(Employee.Position)" Caption="Position" EditorVisible="true"></DxDataGridColumn>
        <DxDataGridDateEditColumn Field="@nameof(Employee.BirthDate)" DisplayFormat="D" EditorFormat="d" 
              Caption="Birth Date" EditorVisible="true"></DxDataGridDateEditColumn>
        <DxDataGridDateEditColumn Field="@nameof(Employee.HireDate)" DisplayFormat="D" EditorFormat="d" 
              Caption="Hire Date" EditorVisible="true"></DxDataGridDateEditColumn>
    </Columns>
    <RowPreviewTemplate Context="ItemInfo">
        @{
            Employee employee = ItemInfo.DataItem;
            <div class="d-flex align-items-start p-1">
                <img src="@(StaticAssetUtils.GetImagePath(employee.ImageFileName))" width="76" />
                <div class="pl-2 text-wrap">@employee.Notes</div>
            </div>
        }
    </RowPreviewTemplate>
</DxDataGrid>

Data Grid Row Preview Template

Run Demo: Data Grid - Row Preview Template

See Also