I'm trying render data in my Jqgrid, but it is just not showing up. My Json data comes from a web server so I'm trying to use Jsonreader as a function to format my data. Can any1 point my mistakes out please. Thanks in advance.
here is my code for the 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');
})
and here is my json information;
[ {
"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}]
Small trailing comma error at the end of colModel
is probably not the main error which you has.
The demo which uses practically your code shows, that the grid should be displayed. It it don't displayed you should include loadError
callback function (see the answer). I suppose that you will have "parsing error" exception which means that you get wrong 'Content-Type' HTTP header value in the server response.