【发布时间】:2011-08-04 18:21:25
【问题描述】:
我在尝试使用 JQGrid 时遇到 JavaScript 错误:
“消息:'undefined' 为空或不是对象”
在我的服务器上调试时,我看到我的 JSON 输出如下所示:(“id”值不在双引号内是否重要?)
{
"page":"1",
"total":"20",
"records":"5",
"rows":[
{"id":1,"name":"Sam","phone":"732-333-2222"},
{"id":2,"name":"Dan","phone":"000-222-1111"},
{"id":6,"name":"George","phone":"333333"},
{"id":4,"name":"Jerry","phone":"332-333-4444"},
{"id":7,"name":"John","phone":"666666"},
{"id":8,"name":"Tom","phone":"3333"}]
}
.. 我的页面如下所示:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
url:'/myUrlPage',
datatype: 'json',
mtype: 'GET',
colNames:['Id', 'Name', 'Phone'],
colModel :[
{name:'id', index:'id', width:55},
{name:'name', index:'name', width:90},
{name:'phone', index:'phone', width:150, sortable:false} ],
pager: jQuery('#pager'),
rowNum:10, rowList:[10,20,30],
sortname: 'id',
sortorder: "desc",
viewrecords: true,
imgpath: 'themes/basic/images',
caption: 'My first grid' }); });
</script>
【问题讨论】:
-
具体错误是“f is undefined”
-
我正在使用:jquery-1.4.2.min.js、grid.locale-en.js、jquery.jqGrid_3.8.2.min.js
标签: jqgrid