Skip to main content

CellEditContext Class

Provides access to information related to the edit template.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v23.1.dll

NuGet Package: DevExpress.Blazor


public class CellEditContext


When you use an edit template for an element, the grid does not know what is changed in editors inside this template during editing. Call the OnChanged method when you change a cell value in a custom editor to inform the grid about the change and save a new cell value to the EditedValues collection. Then, this collection is passed to the RowUpdating and RowInserting events.

<DxDataGrid Data="@DataSource"
    RowUpdating="@((updatingDataItem, newValues) => OnRowUpdating(updatingDataItem, newValues))"
    RowInserting="@((newValues) => OnRowInserting(newValues))">
    <DxDataGridColumn Field="@nameof(Product.Availability)" Caption="Availability" Width="150px">
            <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"))">

    <DxDataGridColumn Field="@nameof(Product.ProductCategoryId)" Caption="Category">
                var cellEditContext = (CellEditContext)context;
                int currentCellValue = (int)cellEditContext.CellValue;
                var nestedItem = NestedDataSource.Where(x => x.ProductSubcategoryID == currentCellValue).FirstOrDefault();
            @* ... *@

@code {
    IEnumerable<Product> DataSource;
    IEnumerable<ProductCategory> NestedDataSource;

    protected override async Task OnInitializedAsync()
        DataSource = await ProductService.LoadAsync();
        NestedDataSource = await ProductCategoriesProvider.GetProductCategoriesAsync();

Online Demo

Data Grid - Templates


See Also