我是jQuery的新手。我在jQuery网格中加载数据时遇到问题。我在jqGrid中显示我的JSON数据时遇到了麻烦。
在我的 firstpage.jsp 上打印jQuery网格,如下所示:
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url: 'nybpayments_feeder.jsp?tranType='+tranType,
mtype:'POST',
datatype:"json",
colNames: ['Acctparty', 'Amount', 'Asofdate','Chipref'],
colModel: [
{ name: 'acctparty', index: 'acctparty', width: 110, align: 'center', sorttype: 'string' },
{ name: 'amount', index: 'bmount', width: 130, align: 'right', sorttype: 'float'},
{name: 'asOfDate', index: 'asOfDate', width: 85, sorttype: 'date', align: 'center',datefmt: 'Y-m-d' },
{ name: 'chipref', index: 'chipref', width: 110, align: 'center', sorttype: 'string' },
],
pager: "#pager",
rowNum: 5,
rowList: [5,10, 20, 30,40],
sortorder: "desc",
viewrecords: true,
gridview: true,
autoencode: true,
height:200,
shrinkToFit:false,
width:1250,
loadonce:true,
caption:"Compressed Billings:"}).navGrid('#pager',{edit:false,add:false,del:false,search:true,refresh:true})
});
来自服务器的结果字符串如下所示:
{"total":10,"page":10,"records":10,"rows":[{"id":"1","cell":["\/IRELAND",1.5955875E8,"2013-12-30",null]},
{"id":"2","cell":["\/IRELAND",1.3453294479E8,"2013-12-30",null]},{"id":"3","cell":[null,1.1684737776E8,"2013-12-30",null]}
在我的 secondpage.jsp 中,我在jsp中打印json字符串,就像这样
response.setContentType("text/json");
ut.println(string);
答案 0 :(得分:0)
您需要在jqgrid中拥有jsonReader
属性。此外,colModel和json对象似乎不匹配。