I'm getting really strange error with jqGrid regarding a TypeError. I've used the grid on many other sites but for whatever reason can't it开发者_JAVA百科 to work on my latest one.
I put in the loadError handler and I get "TypeError: a is null" and Firebug tells me the error is in jquery itself. I've multiple version of both the grid and jQuery -- same result. I made sure my code matched what was on the demoes. Still nothing. Firebug shows the json request went through.
Here's my JSON (it's one row for now):
{"total":6960,"page":1,"records":6960,"rows":[{"id":1000000477,"cell":["some title","brain","7\/15\/2010 at 8:33 AM","sometest",5,277]}]}
Here's my grid set up:
$('#threads').jqGrid({
url: '/pxr/getthreads',
dataType: 'json',
colNames:['Thread / Started By','Last Post','Replies','Views'],
colModel:[{name:'title',index:'title',width:330,sortable:false},
{name:'lastpost',index:'lastpost', width:130,sortable:false},
{name:'replies',index:'replycount', width:60, align:"left",sortable:false},
{name:'views',index:'views', width:60, align:"center",sortable:false}],
rowNum:1,
autowidth:true,
pager: $('div#threadsPager'),
hidegrid:false,
scrollOffset:0,
height: 600,
altRows:false,
sortname: 'lastpost',
viewrecords: true,
emptyrecords: "No Threads Found",
sortorder: 'asc',
pginput:true,
loadError: function(xhr,status,error){
console.log(error);
},
caption:"" });
I'm using jQuery 1.4.4 and jqGrid 3.8. My server page renders valid json.
html:
<table id="threads"></table><div id="threadsPager"></div>
Any ideas?
The error in your code very easy, but can be difficult be seen: you should change dataType: 'json'
to datatype: 'json'
. After the change the data can be loaded: see here.
精彩评论