Skip to main content

GridCustomizeCellDisplayTextEventArgs Class

Contains data for the CustomizeCellDisplayText event.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public abstract class GridCustomizeCellDisplayTextEventArgs :
    GridCustomizeCellDisplayTextEventArgsBase

Remarks

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

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

Inheritance

Object
DevExpress.Blazor.Internal.GridEventArgsBase
DevExpress.Blazor.Internal.GridCustomizeCellDisplayTextEventArgsBase
GridCustomizeCellDisplayTextEventArgs
See Also