Skip to main content

DxGrid.CustomizeCellDisplayText Event

Allows you to customize text displayed within a cell.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public Action<GridCustomizeCellDisplayTextEventArgs> CustomizeCellDisplayText { get; set; }

Parameters

Type Description
GridCustomizeCellDisplayTextEventArgs

A GridCustomizeCellDisplayTextEventArgs object that contains data for this event.

Remarks

You can handle the CustomizeCellDisplayText event or use a column’s DisplayFormat property to customize a cell’s display text.

Use GridCustomizeCellDisplayTextEventArgs (Value, FieldName, etc.) to specify the display format and access other grid data.

Note that if you implement DataColumnCellDisplayTemplate or CellDisplayTemplate, the CustomizeCellDisplayText event fires in the following cases only:

The following code snippet displays the Company Name values in the “Customer”:

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

<DxGrid Data="GridDataSource"
        CustomizeCellDisplayText="Grid_CustomizeCellDisplayText">
    <Columns>
        <DxGridDataColumn FieldName="OrderDate" DisplayFormat="d" />
        <DxGridDataColumn FieldName="Customer" />
        <DxGridDataColumn FieldName="ShipViaNavigation.CompanyName" />
        <DxGridDataColumn FieldName="Freight" DisplayFormat="n2" />
    </Columns>
</DxGrid>

@code {

    object GridDataSource { get; set; }
    NorthwindContext Northwind { get; set; }
    IEnumerable<Customer> CustomerList { get; set; }

    protected override void OnInitialized() {
        Northwind = NorthwindContextFactory.CreateDbContext();
        GridDataSource = Northwind.Orders
        .Include(i => i.Customer)
        .Include(i => i.OrderDetails)
        .Include(i => i.ShipViaNavigation)
        .ToList();
        CustomerList = Northwind.Customers;
    }

    void Grid_CustomizeCellDisplayText(GridCustomizeCellDisplayTextEventArgs e) {
        if (e.FieldName == "Customer") {
            e.DisplayText = CustomerList.Where(p => p.CustomerId == ((Customer)e.Value).CustomerId).FirstOrDefault().CompanyName;
        }
    }

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

DevExpress Blazor Grid - Customize Cell Display Text

See Also