我使用 jqGrid 来显示表格。如果数据是local
,它可以正常工作,但如果它以 JSON 形式给出,则不会显示数据。
我搜索了很多,但没有一个可以解释我的问题。这里有什么建议吗?
Javascript:
jQuery("#gpaTable").jqGrid({
url: "data.html",
datatype: "json",
pager: "#gpaPager",
height: "100%",
colNames: [
"star",
"id",
"name",
"gpa",
"tag",
"failCnt",
"lowScore",
"noScore"],
colModel: [{
name: "star",
index: "star",
width: 20
},
{
name: "id",
index: "id",
width: 80
},
{
name: "name",
index: "name",
width: 80
},
{
name: "gpa",
index: "gpa",
width: 40,
sorttype: "float"
},
{
name: "noScore",
index: "noScore",
width: 80,
sorttype: "int"
},
{
name: "lowScore",
index: "lowScore",
width: 80,
sorttype: "int"
},
{
name: "failCnt",
index: "failCnt",
width: 60,
sorttype: "int"
},
{
name: "tag",
index: "tag",
width: 300
}],
multiselect: true,
caption: "GPA",
viewrecords: true,
jsonReader: {
repeatitems: false,
id: "lineId",
cell: "cell",
root: "rows",
records: "records",
total: "pageTotal",
page: "pageId"
}
});
数据.html:
{
"total": 1,
"page": 1,
"records": 1,
"pageId": 1,
"pageTotal": 1,
"rows": [{
"lineId": 1,
"cell": {
"star": "",
"id": "5090379054",
"name": "BBB",
"gpa": "2.6",
"tag": "",
"failCnt": 2,
"lowScore": 0,
"noScore": 2
}
},
{
"lineId": 2,
"cell": {
"star": "",
"id": "5090379051",
"name": "BBB",
"gpa": "2.1",
"tag": "",
"failCnt": 2,
"lowScore": 0,
"noScore": 2
}
},
{
"lineId": 3,
"cell": {
"star": "",
"id": "5090379052",
"name": "CCC",
"gpa": "3.5",
"tag": "<ul class='tagClass'><li>Tag3</li><li>Tag4</li><li>Tag5</li><li>Tag6</li></ul>",
"failCnt": 0,
"lowScore": 70,
"noScore": 0
}
},
{
"lineId": 4,
"cell": {
"star": "<span class='ui-icon ui-icon-star' value='starred' />",
"id": "5090379032",
"name": "DDD",
"gpa": "1.5",
"tag": "",
"failCnt": 1,
"lowScore": 90,
"noScore": 5
}
},
{
"lineId": 5,
"cell": {
"star": "<span class='ui-icon ui-icon-star' value='starred' />",
"id": "5090379032",
"name": "EEE",
"gpa": "1.2",
"tag": "<ul class='tagClass'><li>Tag3</li></ul>",
"failCnt": 4,
"lowScore": 120,
"noScore": 2
}
}]
}