Add/edit/delete in jqGrid with Web API

佐手、 提交于 2019-12-02 04:16:57

You need to add URL parameter in your editOption, addOption, deleteOption

var editOption = {
    width:400,
    height:290,
    left:20,
    top:30,
    reloadAfterSubmit:false,
    jqModal:false,
    editCaption: "Edit Record",
    bSubmit: "Submit",
    bCancel: "Cancel",
    closeAfterEdit:true,
    url:'http://localhost:50570/api/Test/EditEmployee'
};

var addOption = {
    width:400,
    height:290,
    left:20,
    top:30,
    reloadAfterSubmit:false,
    jqModal:false,
    addCaption: "Add Record",
    bSubmit: "Submit",
    bCancel: "Cancel",
    closeAfterAdd:true,
    url:'http://localhost:50570/api/Test/AddEmployee'
};

var delOption = {
    caption: "Delete",
    msg: "Delete selected record(s)?",
    bSubmit: "Delete",
    bCancel: "Cancel",
    url:'http://localhost:50570/api/Test/DeleteEmployee'
};
`var URL = 'rest/book';`


...
var delOptions = { onclickSubmit: function(params, postdata) { params.url = URL + '/' + postdata; } };

you mean this?


it might need "editurl" in your grid instead of "url" in the del(add/edit)Option,like this:

...

height: 250,
editurl: 'http://localhost:50570/api/Test/',
url: 'http://localhost:50570/api/Test/GetEmployeeSalaries',
mtype: "GET",
contentType: "application/json; charset=utf-8",

... Have a try ?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!