在阅读了大部分问题并试图找到答案之后,我想我放弃了。
所以我遇到的问题就像其他人一样,也就是说,jqGrid不会显示从spring mvc servlet收到的有效json。
这是我的json:
{
"firstRecordIndex": 0,
"pageSize": 20,
"sortDirection": {
"name": "descending",
"code": 1
},
"sortCriterion": "id",
"pageNumber": 1,
"objectsPerPage": 20,
"fullListSize": 1,
"searchId": null,
"totalPages": 1,
"index": 0,
"list": [
{
"issueNumber": "ABC-6799",
"entryDate": 1345763592879,
"billingType": "Non-Billable",
"notes": "Hello",
"customer": "XYZ",
"id": 1,
"hours": 5,
"userName": "John Doe"
}
]
}
这是我的jqGrid:
jQuery(function(){
jQuery("#list").jqGrid({
url:"http://localhost:8080/worktime/timesheet.html?type=list&ajax=true",
datatype: "json",
colNames:["User", "Hours", "Date", "Billing Type", "Notes"],
colModel :[
{name:"userName", width:90, editable:false, jsonmap:"userName", editoptions:{readonly:true,size:10}},
{name:"hours", width:55, editable:true, jsonmap:"hours", editoptions:{size:10}},
{name:"entryDate", width:90, editable:true, jsonmap:"entryDate", formatter:"date", "formatoptions":{"srcformat":"m/d/Y", "newformat":"m/d/Y"},
editoptions:{size:12, dataInit:function(el){jQuery(el).datepicker({dateFormat:"m/d/y"});},defaultValue: "m/d/y"}
},
{name:"billingType", width:100, editable:true, jsonmap:"billingType", edittype:"select", editoptions:{value:"INV:Billable-Invoice;TSA:Billable-TSA;NON:Non-Billable;OH:Overhead"}},
{name:"notes", width:150, sortable:false, editable: true, jsonmap:"notes", edittype:"textarea", editoptions:{rows:"2",cols:"20"}}
],
pager: "#pager",
rowNum:10,
rowList:[10,20,30],
sortname: "entryDate",
sortorder: "asc",
jsonReader: {
root: "list",
total: "totalPages",
page: "pageNumber",
records: "fullListSize",
repeatitems: false,
id: "0"
},
caption: "Timesheet History",
viewrecords: true,
gridview: true,
});
正确的jqGrid配置是什么?我使用的是jqGrid 4.4.0和jQuery 1.7.2。非常感谢您的帮助。谢谢!
答案 0 :(得分:0)
为什么你有这个:id: "0"
?
您的jsonReader
应该是:
jsonReader: {
root: "list",
total: "totalPages",
page: "pageNumber",
records: "fullListSize",
repeatitems: false,
id: "id"
}