1

アクションから jqGrid にデータをロードするときに問題が発生しました

私のアクションはJSONデータを返します:

{"page":"1","records":"31","rows":["{'id':'1','cell':['1','Cant open destop','Destop','Easy','duongls','huyld','minhnq','Finance ','Open']}","{'id':'2','cell':['2','Cant log to email','Email','Normal','thangtd','minhnq','longnh','Secretary ','Assigned']}","{'id':'3','cell':['3','No internet access Edited ver 2 longnh','Connection','Hard','thangtd','longnh','longnh','Secretary ','Closed']}","{'id':'4','cell':['4','Request password','Account','Normal','dungtq','honglm','longnh','Director','Cancelled']}","{'id':'5','cell':['5','Cant open latop','Laptop','Hard','duongls','huyld','minhnq','Director','Closed']}","{'id':'6','cell':['6','issue 11111111111111','','','dungtq','longnh','','Planning','Open']}","{'id':'7','cell':['7','Issue ku minh heo','','','dungtq','longnh','','Planning','Open']}","{'id':'8','cell':['8','New ticket 12345','','','dungtq','longnh','','Planning','Open']}","{'id':'9','cell':['9','Mail server cannot connect','','','haitct','longnh','','Director','Open']}","{'id':'10','cell':['10','aaaaaaaaaaaa','','','dungtq','longnh','','Planning','Open']}"],"total":"4"}

JSP では jqgrid を呼び出します。

$("#list1").jqGrid({                  
        url: "<%=request.getContextPath()%>/pagingIssue?time='+new Date().getTime()",
        colNames:['Id','Name', 'Type','Severity', 'Owner','Register', 'Responsor', 'Department','Status'],
        colModel:[
               {name:'issId',index:'issId', width:40,sortable:true},
               {name:'issName',index:'issName', width:200,sortable:true},
               {name:'issType',index:'issType', width:100,sortable:true},
               {name:'issSeverity',index:'issSeverity', width:100,sortable:true},
               {name:'issOwner',index:'issOwner', width:80,sortable:true},
               {name:'issRegister',index:'issRegister', width:100,sortable:true},
               {name:'issResponsor',index:'issResponsor', width:100,sortable:true},
               {name:'department',index:'department', width:120,sortable:true},
               {name:'issStatus',index:'issStatus', width:80,sortable:true}],
       rowNum:10,
       rowList:[10,15,20],
       pager: '#pager1',
       sortname: 'issId',
       datatype: 'json',
       recordpos: 'left',
       viewrecords: true,
       sortorder: 'desc',
       multiselect: true,
       caption: 'Issue List' });
});

グリッドには読み込み中と表示されます... 助けていただけますか?

4

1 に答える 1

2

デフォルトでは、JSON データは、JSON データの jqGrid ドキュメントに記載されている形式である必要があります

{ 
  "total": "xxx", 
  "page": "yyy", 
  "records": "zzz",
  "rows" : [
    {"id" :"1", "cell" :["cell11", "cell12", "cell13"]},
    {"id" :"2", "cell":["cell21", "cell22", "cell23"]},
      ...
  ]
}

データは近いですがrows、文字列が含まれています

"rows":["{'id' ... ]}"]

オブジェクトの代わりに:

"rows":[{'id' ... ]}]

また、文字列には常に二重引用符を使用し、単一引用符は使用しないでください (詳細については、json.orgのステート マシン図を参照してください)。したがって、JSON は次のようになります。

"rows":[{"id" ... ]}]
于 2012-06-26T18:13:06.043 に答える