DxDataGridColumn.DisplayTemplate Property

Specifies a display template for column cells.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll


public RenderFragment<object> DisplayTemplate { get; set; }

Property Value

Type Description

The template content.


The DisplayTemplate property allows you to specify custom content for column cells. Use the template’s context parameter to access a data object and its fields (for instance, you can get a data field value).

Use the EditTemplate property to define a template for a column editor. If you do not specify the edit template, the column uses a standard editor based on the column type.

The code below demonstrates how to use these properties for the Availability column:

  • The display template uses checkboxes and colored text to visualize column values.
  • The edit template embeds a ComboBox into the edit form and updates a bound field’s value.
<DxDataGrid Data="@DataSource">
    <DxDataGridColumn Field="@nameof(Product.Availability)" Caption="Availability">
                var id = Guid.NewGuid().ToString();
                var inStock = (context as Product).Availability;
                <input id="@id" type="checkbox" checked="@inStock" disabled readonly />
                if (inStock) {
                    <label class="form-check-label text-success" for="@id"><span>In stock</span></label>
                else {
                    <label class="form-check-label text-danger" for="@id"><span>Sold out</span></label>
            <DxComboBox Data="@(new List<string>() { "In stock", "Sold out" })"
                        Value="@(((bool)((CellEditContext)context).CellValue) ? "In stock" : "Sold out" )"
                        ValueChanged="@((string newCellValue) => ((CellEditContext)context).OnChanged(newCellValue == "In stock"))">

DataGrid Display And Edit Templates

Online Demo

See Also