【问题标题】:UnCaught TypeError $(...).kendoGrid is not a functionUnCaught TypeError $(...).kendoGrid 不是函数
【发布时间】:2015-10-02 23:30:26
【问题描述】:

早些时候和今天之前的很多天,我从未收到此错误,我正在返回数据,但由于此错误,它不会显示数据

UnCaught TypeError $(...).kendoGrid 不是函数

我的网格是这个..

    function ShowAdministratorsGrid(administratorData) {
    $("#adminGrid").kendoGrid({
        dataSource: {
            data: administratorData
        },
        columns: [{
            field: "administratorID",
            title: "AdministratorID",
            hidden: true
        },
        {
            field: "administratorName",
            title: "AdministratorName"
        },
        {
            field: "dateCreated",
            title: "DateCreated"
        },
        {
            field: "createdBy",
            title: "CreatedBy"
        }],
        scrollable: true,
        sortable: true,
        pageable: false,
        selectable: "row",
        change: function (e) {
            onRowSelectForAdministrator();
        },
        height: 275
    });
}

我正在这样填充它..

    function ShowAdministratorsInformation() {
    $.ajax({
        type: "GET",
        url: AddURLParam.AddGetAdminInformationURL,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            ShowAdministratorsGrid(data);
        }
    })
}

但正如我所提到的,它直到早些时候才有效,我不知道为什么会抛出这个错误。 我四处寻找与 kendoGrid 相关的错误,但无济于事。

所以直到一两个小时前一切正常。

【问题讨论】:

  • 你是否在页面中添加了剑道 JavaScript 源代码
  • @OsamaJetawe,哦,哇,不,我没有,我一定是不小心把它删掉了。我在我的外部 javascript 文件中引用了它,但从没想过查看我是否仍然在我的视图中引用它,因为我有它。

标签: jquery asp.net-mvc kendo-grid


【解决方案1】:

已记录的解决方案:此问题已记录在案。它说:

小部件不可用或未定义:

如果 jQuery 在页面中多次包含,所有现有的 jQuery 插件(包括 Kendo UI)都将被清除。如果未包含所需的 Kendo JavaScript 文件,也会发生这种情况。

根据浏览器的不同,会抛出以下 JavaScript 错误:

TypeError: Object #<Object> has no method kendoGrid (in Google Chrome)
TypeError: $("#Grid").kendoGrid is not a function (in Firefox)
Object does not support property or method 'kendoGrid' (in Internet Explorer 9 and later)
Object does not support this property or method (in older versions of Internet Explorer)

解决方案:

确保您的页面中不包含多次 jQuery。删除对 j​​Query 的任何重复脚本引用。包括所有必需的 Kendo JavaScript 文件。

jQuery 不可用或未定义:

如果不包含 jQuery,或者包含在 Kendo UI JavaScript 文件之后,或者包含在 Kendo UI 小部件初始化语句之后,则 Kendo UI 小部件将无法按预期运行。将抛出以下 JavaScript 错误(取决于浏览器):

ReferenceError: jQuery is not defined (in Google Chrome and Firefox)
'jQuery' is undefined (in Internet Explorer)

解决方案:

确保仅在 Kendo UI JavaScript 文件和依赖它的任何 Javascript 语句之前包含 jQuery。

Source -Answer

【讨论】:

    【解决方案2】:

    确保您的脚本位于标签&lt;head&gt;...&lt;/head&gt;下方

    <script src="kendo/js/jquery.min.js"> </script>
    

    例子

       <head>
          <title>......</title>
          <script src="kendo/js/jquery.min.js"> </script>
          // and then your other script
       </head>
    

    希望有用

    【讨论】:

      猜你喜欢
      • 2020-04-29
      • 2019-11-06
      • 2017-09-18
      • 2020-06-05
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多