How to use BatchEdit in External Form Editing

I have refer below link to use External Form Editing.It works fine as per given demo.but I would like to know how to update data in Grid Data source using batch mode. I have tried below source to update "Edited Record from external form" but "args.BatchChanges.ChangedRecords" list return null value

protected async Task BatchSaveHandler(BeforeBatchSaveArgs<StyleBomLeatherSetup> args)

{

styleBomLeatherSetupDetails.InsertDetails = args.BatchChanges.AddedRecords;

styleBomLeatherSetupDetails.EditDetails = args.BatchChanges.ChangedRecords;

styleBomLeatherSetupDetails.DeletedDetails = args.BatchChanges.DeletedRecords;

}

Blazor DataGrid External Form Editing Example - Syncfusion Demos






7 Replies

KI KINS December 15, 2021 02:42 AM UTC

Please help,

Its my top most urgent task



JP Jeevakanth Palaniappan Syncfusion Team December 15, 2021 10:03 AM UTC

Hi Kins, 

Greetings from Syncfusion support. 

We have validated your query and we found that the record is updated by using the SetRowData method and this method will update the changes in the datasoure directly. Also the OnBatchSave event will not be triggered while updating the record using SetRowData method. Please find the validated sample below for your reference. 
 

If  you are facing any issues then kindly share us the below details, 

  1. Share us the exact problem/ more information on your query.
  2. Share us the video demo showing the reported problem.
  3. Share us the issue reproducing sample or reproduce the issue in the above provided sample.

Regards, 
Jeevakanth SP. 



KI KINS December 15, 2021 12:48 PM UTC

Thanks for reply..

Instead of "SetRowData" method, which method we are going to use to solve our above issue. Kindly revert back as soon as possible.


Note:

I have use below code to add new record from "external edit form".It works fine and batch handler also working fine.I would like to know how to do for record updating using external form

 public async Task AddRowInBatch()

{

 await gridRef.AddRecordAsync(styleBomLeatherSetup);

{



KI KINS December 16, 2021 02:10 AM UTC

Please help

Awaiting for soonest reply 



JP Jeevakanth Palaniappan Syncfusion Team December 16, 2021 08:22 AM UTC

Hi Kins, 

We suspect that you want to save the cell by using methods. If so we suggest you  to use the UpdateCellAsync method, it will save the modified data in the cell and then when you click on the Update button in toolbar, then only it will update the values in the datasource. If you want to get the modified changes(cell saved changes) then use the GetBatchChanges method. 

Incase if you want to directly update the values in the datasource, you have to use the SetRowData method in which you cannot get changes after updating it. 


    public async Task Save() 
    { 
        if (SelectedData.OrderID != null)         
        { 
            //await this.Grid.SetRowData(SelectedData.OrderID, SelectedData); 
            var Index= await Grid.GetRowIndexByPrimaryKeyAsync(SelectedData.OrderID); 
            await Grid.UpdateCellAsync(Index, "CustomerID", SelectedData.CustomerID); 
            await Grid.UpdateCellAsync(Index, "Freight", SelectedData.Freight); 
            await Grid.UpdateCellAsync(Index, "OrderDate", SelectedData.OrderDate); 
            await Cancel(); 
        } 
    } 

API Reference: 

If this is not your scenario then kindly share the below details, 

  1. Do you want to update the changes directly to datasource or you want to save the changes to cell(Changes will be highlighted in that cell)
  2. Do you want to get the changes after saving the values in the cell?

Regards, 
Jeevakanth SP. 



KI KINS December 16, 2021 03:22 PM UTC

Thanks solved my problem



JP Jeevakanth Palaniappan Syncfusion Team December 17, 2021 05:44 AM UTC

Hi Kins, 

We are glad that the provided solution resolved your query. Get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon