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

GridDataColumnCellDisplayTemplateContext Class

Stores information about a data column cell in the Grid and is passed as the context parameter to the DxGrid.DataColumnCellDisplayTemplate and DxGridDataColumn.CellDisplayTemplate.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public class GridDataColumnCellDisplayTemplateContext :
    GridColumnCellDisplayTemplateContext

Remarks

The DxGrid.DataColumnCellDisplayTemplate and DxGridDataColumn.CellDisplayTemplate accept a GridColumnCellDisplayTemplateContext object as the context parameter. You can use the parameter’s members to get information about the current column cell.

The following example customizes appearance of column cells to distinguish between odd and even rows:

@using Grid.Northwind
@inject NorthwindContext Northwind

<style>
    .my-style {
        color: blue;
        font-weight: bold;
    }
    .my-date-style {
        color: mediumblue;
        font-weight: bold;
    }
</style>

<DxGrid Data="@Data">
    <Columns>
        <DxGridDataColumn FieldName="FirstName" />
        <DxGridDataColumn FieldName="LastName" />
        <DxGridDataColumn FieldName="Title" />
        <DxGridDataColumn FieldName="BirthDate" />
        <DxGridDataColumn FieldName="HireDate" />
    </Columns>
    <DataColumnCellDisplayTemplate>
        @{
            if (context.VisibleIndex % 2 == 1) {
                if (context.DataColumn.FieldName.Contains("Date")) {
                    <span class="my-date-style">@context.DisplayText</span>
                } else {
                    <span class="my-style">@context.DisplayText</span>
                }
            } else {
                <span>@context.DisplayText</span>
            }
        }
    </DataColumnCellDisplayTemplate>
</DxGrid>

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

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

Blazor Grid Column Cell Display Template

Inheritance

Object
GridColumnCellDisplayTemplateContext
GridDataColumnCellDisplayTemplateContext
See Also