我的网格数据读取配置为使用json格式。 这是配置
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",
},
来自客户端的读取请求始终以这种格式发送参数:
_search =假安培; ND = 1317286048991&安培;行数= 25安培;页= 1&安培; SIDX = DEVICE_ID&安培; SORD = ASC&安培; totalrows = 100 我如何将其转换为json格式?
我还设置了postData选项
postData : JSON.stringify({"dev_post_reqtype":"read","dev_post_devndx":"1","dev_post_reccount":"55"}),
它有效,但无法改变
我有寻呼机这个问题。为了在更改页码后进行测试,我将此函数称为
function DEVpager_event(pgevent) {
var page = jQuery("#DEVtbl").getGridParam('page');
alert (pgevent+page) ;
// changed devndx 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); };
页面随我的选择而更改,但postData不会更改 谢谢你的帮助
答案 0 :(得分:4)
如果我理解您的问题,请使用以下表格中的serializeGridData:
serializeGridData: function(postData) {
return JSON.stringify(postData);
}
如果您需要向服务器发送一些其他数据,您可以使用另外
postData: {
dev_post_reqtype: "read",
dev_post_devndx: "1",
dev_post_reccount: "55"
}
或
postData: {
dev_post_reqtype: "read",
dev_post_devndx: 1,
dev_post_reccount: 55
}
取决于您需要的dev_post_devndx
和dev_post_reccount
属性的类型(字符串或整数)。
答案 1 :(得分:-1)
jqGrid的文件......可能是我见过的最糟糕的
试试这个例子:
$("#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');
}