It's a little strange that you need to use HTTP POST, but place the parameters in URL. The parameters in URL will be used typically only in HTTP GET requests, but HTTP GET will be typically cached (in it's not prohibited by HTTP headers). In any way everything is possible.
I'll start with Delete. It's important to understand that formatter:'actions'
uses form editing delGridRow
internally, which options and callbacks are described here. The option url
specify the URL used in the Ajax request and mtype
option can be used to specify HTTP method. Default is mtype: "POST"
. To make dynamic URL you can use for example onclickSubmit
callback, which first parameter (options
) is the reference to internal options of delGridRow
. You can modify the url
property of options
and then jqGrid will use modified URL in the Ajax request which will be send to the server. It's important to understand that the main goal of onclickSubmit
is extending the postdata with additional information. One should return empty object {}
if no additional data need be send. The second parameter of onclickSubmit
is the id or comma-separated list of ids (if you use multiselect: true
). I suppose that you don't use multiselect: true
option and need delete one row only. The resulting code of onclickSubmit
callback will be the following:
onclickSubmit: function (options, rowid) {
options.url = "ListAjaxAccess.cfm?functionName=deleteMember&functionParams=" +
JSON.stringify({id: rowid});
}
If you would use free jqGrid than the place where you can set the callback very easy. See the article. You can include jqGrid option formDeleting
with the property:
formDeleting: {
onclickSubmit: function (options, rowid) {
options.url = "ListAjaxAccess.cfm?functionName=deleteMember&functionParams=" +
JSON.stringify({id: rowid});
}
}
Now any call of Delete row method delGridRow
will use the callback (inclusive formatter: "actions"
).
If you have to use old jqGrid 4.6 and you use formatter: "actions"
, then you should exactly examine the options of formatter: "actions"
here. The corresponding changes in your code will be inside of column which defines formatter: "actions"
. First of all you should never use name: ''
. The name
of every column should corresponds to rules of id
in HTML and the values have to be unique. You can use something like
{
formatter: "actions",
formatoptions: {
delOptions: {
onclickSubmit: function (options, rowid) {
options.url = "ListAjaxAccess.cfm?functionName=deleteMember&functionParams=" +
JSON.stringify({id: rowid});
}
}
}
}
Now back to the second problem: setting dynamic URL of inline editing. It could be relatively tricky because as I wrote placing of parameters in URL is absolutely untypical for HTTP POST. One can use beforeSaveRow
callback to modify the URL dynamically, but the options of the callback don't have the results of modification. So you should confirm that you really require to have the data as parameters of URL and placing the same data in the body of HTTP POST is not an option for you.
UPDATED: If you need to use HTTP GET for inline editing then you should first add the code
$.jgrid = $.jgrid || {};
$.jgrid.inlineEdit = $extend(true, $.jgrid.inlineEdit, {mtype: "GET"});
somewhere at the beginning of your code. It changes the default HTTP method used for inline editing from "POST" to "GET". It's required because formatter: "actions"
of old jqGrid 4.6 version have no possibility to specify mtype
option of inline editing. In free jqGrid one can use mtype: "GET"
inside of formatoptions
property of formatter: "actions"
or alternatively inside of inlineEditing
option of jqGrid: inlineEditing: { mtype: "GET" }
.
To make custom formatting of parameters of inline editing one can use serializeRowData
callback of jqGrid (see here):
editurl: "ListAjaxAccess.cfm",
serializeRowData: function (postData) {
return {
functionName: "editMember",
functionParams: JSON.stringify(postData)
}
}
To use HTTP GET for Delete you can add mtype: "GET"
option to delOptions
described above. Alternatively you can use another form:
{
formatter: "actions",
formatoptions: {
delOptions: {
mtype: "GET",
serializeDelData: function (postData) {
return {
functionName: "deleteMember",
functionParams: JSON.stringify({id: postData.id});
}
}
}
}
Both Edit and Delete will use editurl: "ListAjaxAccess.cfm"
, but there will use different URL parameters.
I have to remark that HTTP GET will be cached in web browser by default. To be sure that one don't use caching I recommend you to set Cache-Control: private, max-age=0
HTTP header in the server response on the URL.