CellEditContext Class

Provides access to information related to the edit template.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.dll

Declaration

public class CellEditContext

Remarks

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">
        <EditTemplate>
            <DxComboBox Data="@(new List<string>() { "In stock", "Sold out" })"
                SelectedItem="@(((bool)((CellEditContext)context).CellValue) ? "In stock" : "Sold out" )"
                SelectedItemChanged="@(newCellValue => ((CellEditContext)context).OnChanged(newCellValue == "In stock"))">
            </DxComboBox>
        </EditTemplate>
    </DxDataGridColumn>

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

Online Demo

Data Grid - Templates

Inheritance

Object
CellEditContext
See Also