CellEditContext Class
Provides access to information related to the edit template.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v24.1.dll
NuGet Package: DevExpress.Blazor
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" })"
Value="@(((bool)((CellEditContext)context).CellValue) ? "In stock" : "Sold out" )"
ValueChanged="@((string 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>
@code {
IEnumerable<Product> DataSource;
IEnumerable<ProductCategory> NestedDataSource;
protected override async Task OnInitializedAsync()
{
DataSource = await ProductService.LoadAsync();
NestedDataSource = await ProductCategoriesProvider.GetProductCategoriesAsync();
}
}
Online Demo
Inheritance
Object
CellEditContext
See Also