Delete record in batch mode

Regards, I am using Syncfusion grid editing in batch mode, I want to delete a record and send the deleted record to server side in order to delete it from a database table. Can you help me with this requirement?






1 Reply

RS Rajapandiyan Settu Syncfusion Team September 30, 2021 10:03 AM UTC

Hi Tarik, 
 
Thanks for contacting Syncfusion support. 
 
We have validated you the provided code example and we suggest use the following code in your server to handle the batch action from the Grid.  
 
 
public void batchUpdate([FromBody]ICRUDModel myObject) 
// it return add , change, delete records based on your action. You can handle as 
        { 
            if (myObject.changed != null && myObject.changed.Count > 0) 
            { 
                foreach (var temp in myObject.changed) 
                { 
                    var ord = temp; 
                    OrdersDetails val = orders.Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); 
                    val.OrderID = ord.OrderID; 
                    val.EmployeeID = ord.EmployeeID; 
                    val.CustomerID = ord.CustomerID; 
                    val.Freight = ord.Freight; 
                    val.OrderDate = ord.OrderDate; 
                    val.ShipCity = ord.ShipCity; 
                    val.ShipName = ord.ShipName; 
                } 
            } 
            if (myObject.added != null && myObject.added.Count > 0) 
            { 
                foreach (var temp in myObject.added) 
                { 
                    orders.Insert(0, temp); 
                } 
            } 
            if (myObject.deleted != null && myObject.deleted.Count > 0) 
            { 
                foreach (var temp in myObject.deleted) 
                { 
                    orders.Remove(orders.Where(or => or.OrderID == temp.OrderID).FirstOrDefault()); 
                } 
            } 
. . . 
        } 
 
 
Please get back to us if you need further assistance of this. 

Regards,
 
Rajapandiyan S 


Loader.
Up arrow icon