How to get unchanged record from batched mode..

Hello Team,


We have this code to get the changed record in batch mode

var ChangedData = await Grid.GetBatchChangesAsync();

in vise versa, how can we get the unchanged row?

var Unchageddata = ?


Warm Regards,

Tyrone


1 Reply

RN Rahul Narayanasamy Syncfusion Team July 19, 2021 12:50 PM UTC

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> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        . ..  
 
    </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 
 


Loader.
Up arrow icon