【问题标题】:jQuery Grid errorjQuery 网格错误
【发布时间】:2011-07-02 06:03:59
【问题描述】:

我正在尝试使用 jQuery 网格。我在 jquery-1.5.1.js 文件中不断收到此错误。 Microsoft JScript 运行时错误:对象不支持此属性或方法

我只是想运行我在这里找到的代码 http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx 作为测试

我在控制器中有这个:

    public JsonResult GridData(string sidx, string sord, int page, int rows)
    {
        int totalPages = 1; // we'll implement later
        int pageSize = rows;
        int totalRecords = 3; // implement later

        var jsonData = new
        {
            total = totalPages,
            page = page,
            records = totalRecords,
            rows = new[]{
                new {id = 1, cell = new[] {"1", "-7", "Is this a good question?"}},
                new {id = 2, cell = new[] {"2", "15", "Is this a blatant ripoff?"}},
                new {id = 3, cell = new[] {"3", "23", "Why is the sky blue?"}}
            }
        };
        return Json(jsonData);
    }

在我的 Index.cshtml 中有以下内容

<script type="text/javascript">
        jQuery(document).ready(function () {
            jQuery("#list").jqGrid({
                url: '/Home/GridData/',
                datatype: 'json',
                mtype: 'POST',
                colNames: ['Id', 'Votes', 'Title'],
                colModel: [
      { name: 'Id', index: 'Id', width: 40, align: 'left' },
      { name: 'Votes', index: 'Votes', width: 40, align: 'left' },
      { name: 'Title', index: 'Title', width: 400, align: 'left'}],
                pager: jQuery('#pager'),
                rowNum: 10,
                rowList: [5, 10, 20, 50],
                sortname: 'Id',
                sortorder: "desc",
                viewrecords: true,
                imgpath: '',
                caption: 'My first grid'
            });
        }); 
</script>  

有人可以指导我做错了什么吗?我从 trirand.com 获得了最新版本的 jqGrid,并将所有文件复制到我的 MVC3 项目的 Script 目录中。
感谢您提供任何帮助。

【问题讨论】:

  • 查看the answer 的更新部分。它包含对您使用的示例的修改。
  • 您好奥列格,感谢您的回复。我在 jqGrid 网站trirand.net/forum/default.aspx?g=posts&t=917 上找到了这个演示并下载了演示。它也给了我一个类似的错误。我的 jqGrid 或 jQuery 版本有问题吗?我确实尝试通过 NuGet 重新安装,但它仍然显示错误,但现在至少当我在错误上单击继续时它显示网格
  • 你从trirand.net/forum/default.aspx?g=posts&t=917下载的项目使用商业版的jqGrid。来自the answerThe project 绝对是另一个例子。它使用 免费开源 版本的 jqGrid,您可以从 here 下载。您使用的 Phil Haack 示例也是基于 jqGrid 的免费开源版本。你想用什么版本?
  • 最好是免费版!我实际上不知道您有免费版本的 jqGrid。我会看看你发布的链接,谢谢。

标签: asp.net-mvc-3 jqgrid


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2016-01-22
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-10
    • 1970-01-01
    • 2014-04-09
    • 1970-01-01
    • 2017-09-28
    相关资源
    最近更新 更多