"Undefined is not a function" 使用仅包含具有 asp.mvc 包装器和数据源的网格的 KendoUI 自定义下载时出错

"Undefined is not a function" error when using a KendoUI custom download containing only the grid with asp.mvc wrapper and Datasource

我正在尝试实现自定义 Kendo 下载,该下载仅包含 ASP.NET MVC 4 项目中的网格,该项目使用 Razor 生成网格,还使用服务器端代码生成网格数据。我在生成这些脚本的自定义下载页面中选择了适用的字段:

我已将脚本和 css 包含在 _layout.cshtml 页面的 header 标签中:

调用网格的代码绑定到具有两个字符串属性(name、desc)并调用控制器操作的简单模型:

@(Html.Kendo().Grid<GridStandAloneTest.Models.GridModel>()
.Name("Grid")
.Sortable()
.Pageable()
.DataSource(ds => ds.Ajax().Read("GetPeople", "Home")
    .Batch(true)
    .ServerOperation(false))
.Columns(x => 
{
    x.Bound(c => c.Name);
    x.Bound(c => c.Salary); 
}))

当页面呈现网格时,网格可见,但永远不会调用控制器操作。我还在控制台中得到一个 "Uncaught TypeError: undefined is not a function" 。但是,如果我单击一个列,它确实会调用控制器操作,但随后它 returns 将它转到一个新选项卡,其中 JSON 数据位于 URL.

控制器代码如下:

    public ActionResult GetPeople([DataSourceRequest]DataSourceRequest DataSource)
    {
        var people = new List<GridStandAloneTest.Models.GridModel>()
        {
            new GridStandAloneTest.Models.GridModel(){Name = "Jon", Salary = "50,000"},
            new GridStandAloneTest.Models.GridModel(){Name = "Joe", Salary = "100,000"}
        };

        DataSourceResult result = people.ToDataSourceResult(DataSource);

        return Json(result, JsonRequestBehavior.AllowGet);
    }

您正在包括 jQuery 1.7.1,而最新版本的 Kendo UI 需要 1.9.1+

http://docs.telerik.com/kendo-ui/install/prerequisites

您至少有 2 个问题:

  1. 您多次包含 jQuery。确保 jQuery 只包含一次,否则网格 js 将中断。
  2. 重现时我注意到 Pager.js 文件似乎没有包含在自定义构建中,即使我选择了它。我得到的错误是 instanceof is not a function 指向它检查寻呼机代码的位置。