0

我的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 显示网格中的所有记录。

4

1 回答 1

1

您如何从演示中看到jsonReader您使用的与返回服务器的数据相对应。

我想您应该检查Content-Type服务器响应的标头。应该是application/json。我建议您另外插入loadError回调以查看哪个错误是空网格的原因。有关更多详细信息,请参阅答案

于 2012-07-18T05:29:41.887 回答