We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Batch mode update. Get data on the server.

I am using standard grid and I am trying to get data on the server.
How to get data on the server when request is send with batch edit mode? I am using this code, but doesn't work:

public IActionResult Update([FromBody]CRUDModel data){}

I am trying and with :
public IActionResult Update(string action, List added, List changed, List deleted, int? key)

, but everything is null, only action string is update.
I see in the browser console the data is send.
------------------------------------------------------------------------------------
Second - when I try to delete row the request is not send. I am using this adaptor:

var dataManager = ej.DataManager({
                url: "/Home/get,
                batchUrl: '/Home/edit',
                adaptor: new ej.UrlAdaptor()
            });


3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team September 20, 2017 07:02 AM UTC

Hi Customer,  
 
We can reproduce the problem at our end. We suggest to enclose the Object type within the CRUDModel class as shown in the following code example.  
 
        public ActionResult BatchUpdate([FromBody]CRUDModel<OrderDetails> myObject) 
        { 
            if (myObject.Changed != null && myObject.Changed.Count > 0) 
            { 
                foreach (var temp in myObject.Changed) 
                { 
                    var ord = temp; 
                  . . . 
                } 
            } 
 
 
            var data = orddata; 
            return Json(data); 
        } 
 
We have prepared a sample that can be downloaded from the following location.  
 
 
Since you are using batch editing in the Grid, the Grid will not send the POST for each action. But it will update the changes (edit/add/delete) of any record in a single post. 
 
Regards,  
Seeni Sakthi Kumar S. 



NO noName September 20, 2017 12:55 PM UTC

When is selected row and pressed button delete, if not send request, how the server will know ?

Or I need to create event for button delete to send request ?

And how to get only edited column on the server, because data.Changed shows me a lot of data like , first column, last column, but not edited column ? 



SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team September 21, 2017 08:35 AM UTC

Hi Customer,  
 
By default, batch editing will bring all the edited records to the server-end which is the default behavior. Refer to the following screenshot. 
 
 
 
If you would like to perform insert or update or delete actions individually, you can use the inline editing. Refer to the following sample demo.  
 
 
In this case, you have to use the insertUrl (adding), updateUrl (editing), and removeUrl(deleting) for performing each action individually.  
 
<div id="Grid"></div> 
 
<script> 
 
 
    $(function () { 
        var dataManager = ej.DataManager({ 
            url: "/Home/get", 
            insertUrl: "/Home/CellEditInsertDetail", 
            updateUrl: "/Home/CellEditUpdateDetail", 
            removeUrl: "/Home/CellEditDeleteDetail", 
            adaptor: new ej.UrlAdaptor() 
        }); 
 
        $("#Grid").ejGrid({ 
            dataSource: dataManager, 
            allowPaging: true, 
            editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, 
 
        }); 
    }); 
</script> 
 
        public ActionResult CellEditInsertDetail([FromBody]CRUDModel<OrderDetails> value) 
        { 
            orddata.Add(value.Value); 
            return Json(value.Value); 
        } 
        public ActionResult CellEditUpdateDetail([FromBody]CRUDModel<OrderDetails> value) 
        { 
            OrderDetails ord = value.Value; 
            OrderDetails val = orddata.Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); 
            val.EmployeeID = ord.EmployeeID; 
                . . 
                        . .  
            return Json(value.Value); 
        } 
        public ActionResult CellEditDeleteDetail([FromBody]CRUDModel<OrderDetails> value) 
        { 
            OrderDetails ord = orddata.Where(or => or.OrderID == int.Parse(value.Key.ToString())).FirstOrDefault(); 
            orddata.Remove(ord); 
            return Json(value); 
        } 
 
 
 
We have modified the sample demo that can be downloaded from the following location.  
 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon