Hi Tyrone,
Thanks for the update.
Query: How to get unchanged record from batched mode.
We have validated your query and you want to get the unchanged record values in batch editing. You can get the unchanged record details by using below way. We have iterated the CurrrentView records and Changed records to get the unchanged record values. Find the below code snippets for your reference.
<button @onclick="Get"> Get UnChanged</button>
<div>@UnChanged.Count</div>
<SfGrid @ref="Grid" DataSource="@Orders" AllowSelection="true" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEvents OnCellSave="CellSaveHandler" CellSelecting="CellSelectingHandler" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridSelectionSettings Mode=SelectionMode.Cell></GridSelectionSettings>
<GridColumns>
. ..
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid;
. ..
public List<Order> UnChanged { get; set; } = new List<Order>();
public async Task Get()
{
UnChanged.Clear();
var ChangedData = await Grid.GetBatchChangesAsync(); //get batch changes
var CurrentView = await Grid.GetCurrentViewRecordsAsync(); // get current view data
for (var i = 0; i < ChangedData.ChangedRecords.Count; i++)
{
if (UnChanged.Count > 1)
{
UnChanged = UnChanged.Where(x => x.OrderID != ChangedData.ChangedRecords[i].OrderID).ToList();
}
else
{
UnChanged = CurrentView.Where(x => x.OrderID != ChangedData.ChangedRecords[i].OrderID).ToList();
}
}
}
. . .
}
|
Please let us know if you have any concerns.
Regards,
Rahul