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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Batch mode update. Get data on the server.

Thread ID:

Created:

Updated:

Platform:

Replies:

132760 Sep 19,2017 05:10 PM UTC Sep 21,2017 08:35 AM UTC JavaScript 3
loading
Tags: ejGrid
noName
Asked On September 19, 2017 05:29 PM UTC

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()
            });


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 


noName
Replied On 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 ? 


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;