我的jqGrid定义是
.
.
.
datatype: 'json', //We specify that the datatype we will be using
url:'<%=request.getContextPath()%>/servlet/AjaxManager?mode=9999&beginindex=0&totallimit=10&colname=policyname&sorttype=asc', // that will return the data
colNames:['Policy Name','Policy Type', 'Time allowed (HH:mm)','Expiration Duration (days)','Session Pulse(minutes)','Description'], //Column Names
colModel :[
{name:'policyname', index:'policyname', editable:true,sorttype:'text',width:150,editoptions:{size:30,maxlength:50}, frozen : true,editrules:{required:true},formatter:'showlink',formatoptions:{baseLinkUrl:'javascript:' , showAction: "GetAndShowUserData(jQuery('#list2'),'",addParam: "');"}},
{name:'policytype', index:'policytype', sorttype:'text',editable:true,edittype:"select",editrules: {edithidden:true},editoptions:{value:"POST:Postpaid;PRE:Prepaid"}},
{name:'allotedminutes', index:'allotedminutes',resizable:false, sorttype:'text',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'expiredays', index:'expiredays', sorttype:'text',editable:true,width:200, align:"right",editrules:{integer: true},editoptions:{size:5, maxlength:4}},
{name:'sessionpulse', index:'sessionpulse',sorttype:'int',editable:true,width:200, align:"right"},
{name:'policydescription', index:'policydescription', sortable:false,editable:true,sorttype:"date"}],
.
.
.
jsonReader : {
root: "ROWS", //our data
page: "CURRENTPAGE", //current page
total: "TOTAL", //total pages
repeatitems: true,
id: "id",
cell: "cell",
userdata:"USERDATA", //Userdata we will pass back for feedback
records: "TOTALRECORDS" //total records
},
.
.
.
我的JSON值是
{"TOTAL":1,"CURRENTPAGE":1,"TOTALRECORDS":1,"ROWS":[{"id":1,"cell":["Unlimited Policy","Absolute","Unlimited","Unlimited",1,"2007-12-03"]},{"id":2,"cell":["1 Month Unlimited policy","Absolute","Unlimited",30,1,"2007-12-03"]},{"id":3,"cell":["100 Hours policy","Absolute","100:00","Unlimited",1,"2007-12-03"]}]}
但是我无法将JSON数据加载到jqGrid中。这里jqGrid显示网格中的任何记录。
答案 0 :(得分:1)
如何从the demo看到您使用的jsonReader
对应于返回服务器的数据。
我想您应该检查服务器响应的Content-Type
标头。它应该是application/json
。我建议您另外插入loadError
回调以查看哪个错误是空网格的原因。有关详细信息,请参阅the answer。