jqGrid typeerror jQuery的 [英] jqGrid typeerror jquery

查看:79
本文介绍了jqGrid typeerror jQuery的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于TypeError的jqGrid,我收到了非常奇怪的错误.我在许多其他站点上都使用了网格,但是由于某种原因,它无法在我的最新站点上使用.

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 to work on my latest one.

我放入了loadError处理程序,并得到"TypeError:a为null",Firebug告诉我错误出在jquery本身.我有网格和jQuery的多个版本-结果相同.我确保我的代码与演示中的代码匹配.依然没有. Firebug显示JSON请求已通过.

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.

这是我的JSON(现在是一行):

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]}]}

这是我的网格设置:

$('#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:"" });

我正在使用jQuery 1.4.4和jqGrid 3.8.我的服务器页面呈现了有效的json.

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>

有什么想法吗?

推荐答案

代码中的错误非常容易,但是很难看出:您应该将dataType: 'json'更改为datatype: 'json'.更改之后,可以加载数据:请参见此处.

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.

这篇关于jqGrid typeerror jQuery的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆