在阅读了大部分问题并试图找到答案之后,我想我放弃了。
所以我遇到的问题就像其他人遇到的一样,即 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。非常感谢您的帮助。谢谢!!