这是我的java服务
@RequestMapping(value="/refreshInterviewServiceList1", method = RequestMethod.GET)
public @ResponseBody JSONObject refreshInterviewServiceList1() throws JSONException{
List<ReportInterview> reportInterview = reportInterviewServiceImpl.findByReportId(reportId);
JSONObject output = new JSONObject();
JSONArray toplevel = new JSONArray();
output.put("page", 1);
output.put("records", reportInterview.size());
output.put("total",1);
for(int i = 0;i<reportInterview.size();i++){
JSONObject data = new JSONObject();
JSONArray data1 = new JSONArray();
data.put("id", i+1);
data1.put(reportInterview.get(i).getName());
data1.put(reportInterview.get(i).getOccupation());
data.put("cell", data1);
toplevel.put(data);
}
output.put("rows", toplevel);
System.out.println(output);
return output;
}
这是我的 javascript
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery("#projectTable").jqGrid({
url: 'refreshInterviewServiceList1',
datatype: "json",
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: true,
cell: "cell",
id: "id"
},
colNames:['Id','Name','Occupation'],
colModel:[
{name:'id',index:'id', width:10},
{name:'name',index:'name', width:10},
{name:'occupation',index:'occupation', width:10}
],
rowNum:10,
rowList:[10,20,30],
height:460,
width:700,
pager: "#pagingDiv",
viewrecords: true,
caption: "Projects"
});
});
我的 json 对象的输出
{
"total": 1,
"page": 1,
"records": 2,
"rows": [
{
"id": 1,
"cell": [
"232",
"12"
]
},
{
"id": 2,
"cell": [
"45",
"454"
]
}
]
}
我现在的问题是 jqgrid 无法在 jqgrid 中显示 json 数据...仅显示空白列表...请帮助...谢谢!