我正在尝试在我的 jqGrid 上显示来自服务器的数据。它可以正常获取数据但不显示任何内容。
这是我的代码:
HTML
<link href="css/jqGrid.css" rel="stylesheet" media="screen"/>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.jqGrid.min.js"></script>
<table id="mapGrid"></table>
<div id="mapGridPager"></div>
JS
function initGrid() {
var gridOption = {
caption: 'Locations',
url: 'report/search?',
height: '500',
width: '500',
colNames:['Event ID', 'DateTime','Latitude', 'Longitude', 'Address'],
colModel:[ {name:'eventId', index:'eventId', align:'center', width:40, fronzen:true},
{name:'timestamp',index:'timestamp', align:'center', width:100, fronzen:true},
{name:'latitude',index:'latitude', width:100},
{name:'longitude',index:'longitude', width:100},
{name:'address',index:'address', width:200}
],
emptyrecords: 'Nothing to display',
rowNum:30,
mtype: "GET",
rownumbers: true,
gridview: true,
page : 1,
pager: '#mapGridPager',
sortname: 'eventId',
viewrecords: true,
sortorder: "asc",
shrinkToFit: false,
beforeRequest: function(){
return false;
}
};
$('#mapGrid').jqGrid(gridOption)
.navGrid(gridOption.pager, {edit:false,add:false,del:false,refresh:false,search:false});
}
JSON数据
{
"total":1,
"page":1,
"records":22,
"rows":[
{
"eventId":1,
"accountId":"demo",
"deviceId":"demo",
"timestamp":"16-01-1970 02:20:25",
"statusCode":61714,
"latitude":38.4465157985687,
"longitude":-121.857991218567,
"altitude":19.0,
"address":"Dixon, CA"
},
//21 more
]
}
每条记录的事件 ID 都是唯一的。
我该如何解决这个问题?