- Home
- Forum
- JavaScript - EJ 2
- Copy records from Grid1 to Grid2 manually add more records save all records using batch mode
Copy records from Grid1 to Grid2 manually add more records save all records using batch mode
Hi Guys I have been trying to do the following with little success:
My platform is latest Syncfusion version , Asp .Net Core 8 and razor pages.
What I am trying to do:
- Grid 1 has records and a check box to select records.
- I copy records from Grid 1 to Grid 2
- I the manually add a fey more records to Grid 2
- I need to be able to save copied and added records using batchSave to my backend (ef)
Hi Edmund Herbert,
Greetings from Syncfusion support.
Upon reviewing the provided information, we have noted that you are utilizing two Syncfusion Grid components and encountering an issue with copying and pasting records from one Grid to another, where the pasted records are not being saved. We have created a sample based on the provided details and attempted to replicate the reported issue but were unsuccessful. Please refer to the below code example, attached sample and video demonstration, where we copied records from Grid 1 and pasted them into Grid 2, along with manually adding a record. These records are saved properly in Grid 2.
|
Index.js var data = new ej.data.DataManager({ url: 'http://localhost:5000/api/Grid', batchUrl: 'http://localhost:5000/api/Grid/BatchUpdate', adaptor: new ej.data.UrlAdaptor() }); // First Grid var grid = new ej.grids.Grid({ dataSource: data, allowSorting: true, toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel', 'Search'], editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch', }, selectionSettings: { type: 'Multiple', mode: 'Cell', cellSelectionMode: 'Box' }, columns: [ …………………., ], }); grid.appendTo('#Grid'); // Second Grid var grid2 = new ej.grids.Grid({ dataSource: data, allowSorting: true, toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel', 'Search'], editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch', }, selectionSettings: { type: 'Multiple', mode: 'Cell', cellSelectionMode: 'Box' }, columns: [ …………………., ], }); grid2.appendTo('#Grid2');
|
|
GridController.cs // Handling Batch update public IActionResult BatchUpdate([FromBody] CRUDModel<OrdersDetails> batchmodel) { if (batchmodel.Changed != null) { for (var i = 0; i < batchmodel.Changed.Count(); i++) { var ord = batchmodel.Changed[i]; OrdersDetails val = order.Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); val.OrderID = ord.OrderID; val.EmployeeID = ord.EmployeeID; val.CustomerID = ord.CustomerID; val.ShipCity = ord.ShipCity; } } if (batchmodel.Deleted != null) { for (var i = 0; i < batchmodel.Deleted.Count(); i++) { order.Remove(order.Where(or => or.OrderID == batchmodel.Deleted[i].OrderID).FirstOrDefault()); } } if (batchmodel.Added != null) { for (var i = 0; i < batchmodel.Added.Count(); i++) { order.Insert(0, batchmodel.Added[i]); } } var data = order.ToList(); return Json(data); }
|
Sample and Video Demo: Please find the attachment.
If you continue to experience issues, please attempt to replicate the problem in the attached sample or provide a simple sample demonstrating the issue, along with a video demonstration for further validation.
Regards
Aishwarya R
Attachment: 194479SampleAndVideoDemo_c6fffc29.zip
- 1 Reply
- 2 Participants
-
EH Edmund Herbert
- Sep 20, 2024 04:08 AM UTC
- Sep 25, 2024 10:04 AM UTC