我尝试在我的Jqgrid中渲染数据,但它就是不显示。我的Json数据来自web服务器,所以我尝试使用Jsonreader作为一个函数来格式化我的数据。能请any1指出我的错误吗?提前谢谢。
下面是我的jqgrid代码:
jQuery(document).ready(function(){
jQuery("#grid").jqGrid({
url: 'localhost/webair/contactinfoes',
datatype: 'json',
ajaxGridOptions: { contentType: "application/json" },
colNames: ['Company','Firstname','Job Title','Last Update Time', 'Last Update User',
'Lastname', 'Uuid'],
colModel: [
{ name: 'comapany', width: 100},
{ name: 'firstname', width: 60},
{ name: 'jobtitle', width: 100},
{ name: 'lastupdatetime', width: 250, align: 'right' },
{ name: 'lastupdateuser', width: 100, align: 'right' },
{ name: 'lastname', width: 60 },
{ name: 'uuid', width: 250},
],
jsonReader: {
repeatitems: false,
root: function (obj) { return obj; },
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.length; }
},
rowNum:10,
rowList:[10,20,30],
pager: '#pager10',
viewrecords: true,
caption:"Terry's table",
}).navGrid('#gridpager');
})这是我的json信息;
[ {
"cel":"asdf",
"company":"adsf",
"fax":"asdf",
"firstname":"asdf",
"id":98304,
"jobTitle":"asdf",
"lastUpdateTime":1331831984277,
"lastUpdateUser":"anonymousUser",
"lastname":"berk",
"phone":"adsf",
"uuid":"2asa8a2-d2b5-48a2-ba35-b0cfasdf3170f",
"version":0}]发布于 2012-03-16 08:30:26
colModel末尾的小逗号错误可能不是您的主要错误。
实际使用您的代码的The demo显示,网格应该被显示。如果没有显示,则应该包含loadError回调函数(参见the answer)。我假设你会有"parsing error“异常,这意味着你在服务器响应中得到了错误的”Content-Type“HTTP头值。
https://stackoverflow.com/questions/9730055
复制相似问题