Cell edit demos fixed to mark the cell as edited properly

This commit is contained in:
Vladimir Enchev
2026-03-16 08:52:53 +02:00
parent 50d0add033
commit 3e3edc679f
2 changed files with 5 additions and 4 deletions

View File

@@ -168,13 +168,12 @@ ColumnWidth="200px" CellClick="@OnCellClick">
/// <param name="args"></param>
async Task OnCellClick(DataGridCellMouseEventArgs<Order> args)
{
if (!grid.IsValid ||
if (!grid.IsValid ||
(ordersToUpdate.Contains(args.Data) && columnEditing == args.Column.Property)) return;
// Record the previous edited field, if you're not using IRevertibleChangeTracking to track object changes
// Commit any pending edit before switching to the new cell.
if (ordersToUpdate.Any())
{
editedFields.Add(new(ordersToUpdate.First().OrderID, columnEditing));
await Update();
}
@@ -205,6 +204,8 @@ ColumnWidth="200px" CellClick="@OnCellClick">
if (ordersToUpdate.Any())
{
// Record the edited field so the cell gets the "edited" indicator.
editedFields.Add(new(ordersToUpdate.First().OrderID, columnEditing));
await grid.UpdateRow(ordersToUpdate.First());
}
}

View File

@@ -141,7 +141,6 @@
if (tasksToUpdate.Any())
{
editedFields.Add(new(tasksToUpdate.First().Id, columnEditing));
await Update();
}
@@ -169,6 +168,7 @@
if (tasksToUpdate.Any())
{
editedFields.Add(new(tasksToUpdate.First().Id, columnEditing));
await gantt.UpdateRow(tasksToUpdate.First());
}
}