jqgrid post request data json
My grid data read is configured for use json format. This is the configuration
url:"devitem.json",
mtype: "POST",
datatype: "json",
ajaxGridOptions: {
type : 'post',
async : false,
error : function() { alert('Something bad happened. Stopping');},
},
jsonReader : {
root : "rows",
page : "page",
total : "total",
records : "records",
repeatitems : true,
cell : "cell",
id : "0",
userdata : "userdata",
},
The read request from client send always parameters in this format:
_search=false&nd=1317286048991&rows=25&page=1&sidx=device_id&sord=asc&totalrows=100 How I can convert it to json format ?
I have also set the postData option
postData : JSON.stringify({"dev_post_reqtype":"read","dev_post_devndx":"1","dev_post_reccount":"55"}),
It work but obiuovsly cannot be changed
I have this problem with pager. For testing after change the page number I call this function
function DEVpager_event(pgevent) {
var page = jQuery("#DEVtbl").getGridParam('page');
alert (pgevent+page) ;
// changed devnd开发者_如何学Gox for test only
var jdata = JSON.stringify({"dev_post_reqtype":"read","dev_post_devndx":"25","dev_post_reccount":"55"}) ;
jQuery("#DEVtbl").jqGrid('setGridParam', 'postData', jdata); } ;
page is changed with my selection but postData don't change thanks for help
If I understand correct your problem you should use serializeGridData in about the following form:
serializeGridData: function(postData) {
return JSON.stringify(postData);
}
If you need send some additional data to the server you can use additionally
postData: {
dev_post_reqtype: "read",
dev_post_devndx: "1",
dev_post_reccount: "55"
}
or
postData: {
dev_post_reqtype: "read",
dev_post_devndx: 1,
dev_post_reccount: 55
}
depend on the type of dev_post_devndx
and dev_post_reccount
properties which you need (string or integer).
The documentations of jqGrid... probably the worst I have ever seen
Try with this example:
$("#wlistt").jqGrid('navGrid','#pagerwlist',
{ add: true, edit: true, del: true },
{// settings for edit
afterShowForm:afterShowEdit,
afterSubmit:processAddEdit,
beforeSubmit:validateData,
closeAfterAdd: true,
closeAfterEdit: true
}
,{// settings for add
afterShowForm:afterShowAdd,
afterSubmit:processAddEdit,
beforeSubmit:validateData,
closeAfterAdd: true,
closeAfterEdit: true
}
,{} // settings for delete
);
}
}
function afterShowEdit(formId) {
alert('show_edit');
}
function afterShowAdd(formId) {
alert('show_add');
}
function processAddEdit(formId) {
alert('proc_add');
}
function validateData(formId) {
alert('val_dat');
}
精彩评论