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/jsonloadErrorさらにコールバックを挿入して、空のグリッドの原因となったエラーを確認することをお勧めします。詳細については、回答を参照してください。

于 2012-07-18T05:29:41.887 に答える