How you can find in the code of grid.base.js the $.ajax
call filling the grid contain looks like following:
$.ajax($.extend({
url: ts.p.url,
type: ts.p.mtype,
dataType: dt,
data: $.isFunction(ts.p.serializeGridData) ?
ts.p.serializeGridData.call(ts, ts.p.postData) : ts.p.postData,
complete: function (req, st) {
...
}
...
}, $.jgrid.ajaxOptions, ts.p.ajaxGridOptions));
So you can use ajaxGridOptions
option of jqGrid to set or override any parameter of $.ajax
request. Because I use only JSON requests to my server, I set general setting of contentType
like
$.extend($.jgrid.defaults, {
datatype: 'json',
{ajaxGridOptions: { contentType: "application/json" },
{ajaxRowOptions: { contentType: "application/json", type: "PUT" },
...
});
The ajaxRowOptions
are used in grid.inlinedit.js for row editing. For the form edit there are other parameters, which I set also as global setting:
$.extend($.jgrid.edit, {
ajaxEditOptions: { contentType: "application/json" },
...
});
$.extend($.jgrid.del, {
ajaxDelOptions: { contentType: "application/json" },
mtype: "DELETE",
...
});
How you can see my server is a RESTfull service (developed mainly in WFC and the rest in ASP.NET MVC). Because $.jgrid.edit
is a setting for both "add" and "modify" items, I could not change mtype: "PUT"
for "edit" only, so I do this in parameters of navGrid()
.
The last ajax parameter which you could find also interesting to set is ajaxSelectOptions
. You can set it on the same way as ajaxGridOptions
. Parameters of ajaxSelectOptions
are useful if you use dataUrl
parameter inside of editoptions
or searchoptions
. I use, for example, dataUrl
inside of colModel
for defining columns of the type edittype: 'select'
. The possible values of select option will be loaded from server for inline or form editing or inside of search dialog. Because for such data loading are used ajax, there is corresponding ajaxSelectOptions
option.
Best regards.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…