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

Update row JS grid

Thread ID:

Created:

Updated:

Platform:

Replies:

132485 Sep 4,2017 05:40 PM UTC Sep 7,2017 04:54 AM UTC JavaScript 5
loading
Tags: ejGrid
noName
Asked On September 4, 2017 06:00 PM UTC

I have this JS:
var dm = ej.DataManager({
url: "/Home/get", crossDomain: true,
updateUrl: '/Home/update',
adaptor: new ej.UrlAdaptor()
});
$("#Grid").ejGrid({
dataSource: dm,
filterSettings: {
filterType: "menu"
},
pageSettings: { enableQueryString: true, pageSize: 10 },
toolbarSettings: { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel", "search"] },
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
columns: [
{ field: "data", headerText: "Data", isPrimarykey: true },
{ field: "value", headerText: "Value" },
]
});
which creates grid. If I try to change info in some row it sends update request to the given URL, which is JSON value .
How to catch the value parameter on the server ?
How can I send another parameter like id of the row data which is updated?

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 5, 2017 08:36 AM UTC

Hi Customer,  
 
Thanks for contacting Syncfusion Support.  
 
Query #1: How to catch the value parameter on the server ? 
 
We could see you are looking for the CRUD action handlers in the Grid with required parameters. Refer to the following code example and Help Document. 
 
        public ActionResult Update([FromBody]CRUDModel<Project> myObject) 
        { 
            var updateData = myObject.Value; 
            . ..  
               . . . 
            return Json(myObject.Value);             
        } 
 
 
Query #2: How can I send another parameter like id of the row data which is updated? 
 
We recommend to pass the value of the primary key to the server end, for updating the values to the database. This can be achieved by using the custom headers of the DataManager. We have already discussed about this in the following Kb.  
 
 
The ID value sent to the server end using the custom headers has been used to retrieve the records of the parent Grid and from there we have traversed current slave Grid’s record. Refer to the following code example.  
 
        public ActionResult CellEditInsertDetail([FromBody]CRUDModel<AlarmModel> value) 
        { 
            int readonlyID = int.Parse(Request.Headers["ID"]); 
            return Json(value.Value); 
        } 
 
            $("#Grid").ejGrid({ 
                dataSource: ej.DataManager({ 
                    url: "/Home/DataSource", 
                    updateUrl: "/Home/Update", 
                    adaptor: new ej.UrlAdaptor() 
                }), 
                actionBegin: function (args) { 
                    if (args.requestType == "save") 
                        this.model.dataSource.dataSource.headers = [{ ID: args.rowData.OrderID }]; 
                }, 
                . ..  
            }); 
 
Regards,  
Seeni Sakthi Kumar S. 


noName
Replied On September 5, 2017 03:54 PM UTC

Hi, thanks It works. Just one thing. For now I am not using headers for ID, but I get Id from:

[FromBody]CRUDModel<Project> myObject

with:

Guid ID = Guid.Parse(myObject.Key.ToString());

, because The ID is there when I check in the console:

  1. Recuest headers:
  2. field:
    ID
  3. Host:
    localhost:23180
  4. IsValid:
    true

, but when I try to get it like this:

int readonlyID = int.Parse(Request.Headers["ID"]); 

it is null.

Other thing is for the insert I am using same param:

public IActionResult Create([FromBody]CRUDModel data)

, but data is null. I see from the console it is send to the server.


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 6, 2017 05:26 AM UTC

Hi Customer,  
 
Query #1: Custom Headers is null 
 
We suspect that you are not sending value as shown in our previous example. Please refer to the following code example and output.  
 
        public ActionResult CellEditInsertDetail([FromBody]CRUDModel<AlarmModel> value)  
        {  
            int readonlyID = int.Parse(Request.Headers["ID"]);  
            return Json(value.Value);  
        }  
  
            $("#Grid").ejGrid({  
                dataSource: ej.DataManager({  
                    url: "/Home/DataSource",  
                    updateUrl: "/Home/Update",  
                    adaptor: new ej.UrlAdaptor()  
                }),  
                actionBegin: function (args) {  
                    if (args.requestType == "save")  
                        this.model.dataSource.dataSource.headers = [{ ID: args.rowData.OrderID }];  
                },  
                . ..   
            }); 
 
 
 
Query #2: Insert Operation not receiving the data 
 
We could see the absence of Model Class in the parameter which might cause this problem. So, we suggest reframe your code as follows.  
 
 
        public ActionResult Insert([FromBody]CRUDModel<Project> myObject)  
        {  
            return Json(myObject.Value);              
        } 
 
 
Regards,  
Seeni Sakthi Kumar S. 


noName
Replied On September 6, 2017 03:34 PM UTC

Hi, thx, Query 1 is fixed.

About Query 2, yes I set the model name here [FromBody]CRUDModel<ModelName> myObject.

, but myObject is still null. What I do is exact: [FromBody]CRUDModel<Object> data, Object, but not Model name and now everything works. 



Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 7, 2017 04:54 AM UTC

Hi Jim,  
 
Thanks for the update.  
 
We are happy to hear that your problem has been resolved. Please get back to us, if you require further assistance on this. 
 
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

;