Jqgrid editurl: controller action parameters

When I use the editurl property in my jqgrid, the controller action is called after I clicked the submit button when adding a new row. But how do I get all the grid lines? Which parameter should be read from my controller action method to get grid data?

Summary Code:

$("#list1").jqGrid({
            url: '/CMS/GetCustomLanguageData',
---
---                
editurl: '/CMS/SaveCustomLanguageData'
---

Add new line code:

grid.jqGrid('editGridRow',"new",{height:280,reloadAfterSubmit:false,addCaption: "Add Record",
    editCaption: "Edit Record",
    bSubmit: "Submit",
    bCancel: "Cancel",
    bClose: "Close",
    saveData: "Data has been changed! Save changes?",
    bYes : "Yes",
    bNo : "No"
});

Controller Code:

public ActionResult SaveCustomLanguageData()
{
}
+4
source share
1 answer

jqGrid sends named parameters to the controller with the name you define in the "name" property colModel. Additionally will be shipped oper=addand id=_empty. So your controller action might look like this

public JsonResult SaveCustomLanguageData (string id, string oper, MyObject item)
{
    // test id for "_empty" or oper for "add".
    // If so add the item and return the value of the new id
    // for example return Json ("123");
}

JSON, ,

jQuery.extend(jQuery.jgrid.edit, {
    afterSubmit: function (response, postdata) {
        return [true, "", jQuery.parseJSON(response.responseText)];
    }
});
+4

All Articles