Skip to main content

GridCustomizeCellDisplayTextEventArgs Class

Contains data for the CustomizeCellDisplayText event.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v21.2.dll

Declaration

public abstract class GridCustomizeCellDisplayTextEventArgs

Remarks

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

Note that if you use the DataColumnCellDisplayTemplate or CellDisplayTemplate, the CustomizeCellDisplayText event does not fire.

The example below illustrates how to display 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

Inheritance

Object
GridCustomizeCellDisplayTextEventArgs
See Also