$.jgrid.del
defined defaults used by all jqGrids on the page. $.extend
just combines the properties of the parameter (mtype
, serializeDelData
, onclickSubmit
and afterComplete
) with the properties with the same name which could exist in $.jgrid.del
. Thus jqGrid uses the object $.jgrid.del
not during creating the grid, but during executing Delete operation then the code like
$.extend($.jgrid.del, {...}); // first settings
$("#grid1").jqGrid({
...
}).jqGrid("navGrid");
$.extend($.jgrid.del, {...}); // the second settings
$("#grid2").jqGrid({
...
}).jqGrid("navGrid");
will use only the second settings of $.jgrid.del
.
Thus you should to use $.extend($.jgrid.del, {...});
to set common defaults on the page and to set other parameters separately:
$.extend($.jgrid.del, {
mtype: "DELETE",
serializeDelData: function () {
return ""; // don't send and body for the HTTP DELETE
}
});
$("#grid1").jqGrid({
...
}).jqGrid("navGrid", ....., { /*Del options*/
onclickSubmit: function (params, postdata) {
params.url = 'url1' + postdata;
}
});
$("#grid2").jqGrid({
...
}).jqGrid("navGrid", ....., { /*Del options*/
onclickSubmit: function (params, postdata) {
params.url = 'url2' + postdata;
}
});
If you use free jqGrid fork, which I develop, then you can specify Delete parameters inside of formDeleting
option of jqGrid. Additionally, free jqGrid supports functions as the value of url
(see the answer for more details) and you can rewrite the above code as following
$.extend($.jgrid.del, {
mtype: "DELETE",
serializeDelData: function () {
return ""; // don't send and body for the HTTP DELETE
}
});
$("#grid1").jqGrid({
...
formDeleting: {
url: function (rowid) {
return "url1/" + rowid;
}
}
}).jqGrid("navGrid");
$("#grid2").jqGrid({
...
formDeleting: {
url: function (rowid) {
return "url2/" + rowid;
}
}
}).jqGrid("navGrid");
Of cause if you set editurl
to the base URL in every grid then you could access it from url
function and rewrite the code as below
$.extend($.jgrid.del, {
mtype: "DELETE",
serializeDelData: function () {
return ""; // don't send and body for the HTTP DELETE
},
url: function (rowid, postData, options) {
return options.url + rowid;
}
});
$("#grid1").jqGrid({
...
editurl: "url1/"
}).jqGrid("navGrid");
$("#grid2").jqGrid({
...
editurl: "url2/"
}).jqGrid("navGrid");