Javascript 运行时错误:“对象不支持属性或方法"在 Internet Explorer 中 [英] Javascript runtime error: "object doesn't support property or method" in Internet Explorer

查看:15
本文介绍了Javascript 运行时错误:“对象不支持属性或方法"在 Internet Explorer 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用剑道网格,它们适用于 CRUD 操作.现在,我想通过将 .Filterable() 选项添加到网格的规范中来添加过滤.这是一些代码:

@(Html.Kendo().Grid().Name("datagrid_Concessions").Columns(columns =>{columns.Bound(c => c.Code).Title("Code");columns.Bound(c => c.Description).Title("Description");columns.Bound(c => c.TrafficOpeningDate).Title("Traffic Opening Date");columns.Bound(c => c.CreationDate).Title("创建日期");}).HtmlAttributes(new { style = "height: 534px;" }).Filterable()//这是可过滤选项.Selectable().Events(e => e.Change("onChange")).Pageable(pageable => pageable.刷新(真)).DataSource(dataSource => 数据源.Ajax().PageSize(15).Read(read => read.Action("GetConcessions", "MasterData"))))

网格呈现完美,现在网格的列标题上显示小过滤器图标:

但是当我单击一个时,弹出窗口打开半秒钟并抛出错误.我正在使用 Visual Studio 2010 并且调试器显示一个弹出窗口javascript 运行时错误:对象不支持属性或方法addBack".

此外,它打开文件 kendo.all.min.js 并突出显示方法 addBack 所在的一行代码.

注意:我已经在 Chrome 和 Firefox 上进行了测试,效果很好.该问题仅在使用 Internet Explorer(版本 11)时存在.

有什么帮助吗?

解决方案

确保你有 Jquery-1.8.1.min.js 或更高版本的 jquery您的页面.因为 addBack 是在 1.8 中添加的.

试试这个,

 @(Html.Kendo().Grid().Name("datagrid_Concessions").Columns(columns =>{columns.Bound(c => c.Code).Title("Code");columns.Bound(c => c.Description).Title("Description");columns.Bound(c => c.TrafficOpeningDate).Title("Traffic Opening Date");columns.Bound(c => c.CreationDate).Title("创建日期");}).HtmlAttributes(new { style = "height: 534px;" }).Filterable()//这是可过滤选项.Selectable().Events(e => e.Change("onChange")).Pageable(pageable => pageable.刷新(真)).DataSource(dataSource => 数据源.Ajax().PageSize(15).Model(model => <--- 添加这个{模型.Id(m => m.Id);模型.字段(m => m.Code);模型.字段(m => m.Description);}).Read(read => read.Action("GetConcessions", "MasterData"))))

查看此演示:http://jsbin.com/emuqazEz/4/edit

I'm using kendo grids and they work fine for the CRUD operations. Now, I wanted to add filtering by adding the .Filterable() option to the grid's specification. Here's some code:

<div id="datagrid">
    @(Html.Kendo().Grid<SustIMS.Models.ConcessionModel>()
    .Name("datagrid_Concessions")
    .Columns(columns =>
    {
        columns.Bound(c => c.Code).Title("Code");
        columns.Bound(c => c.Description).Title("Description");
        columns.Bound(c => c.TrafficOpeningDate).Title("Traffic Opening Date");
        columns.Bound(c => c.CreationDate).Title("Creation Date");
    })
    .HtmlAttributes(new { style = "height: 534px;" })
    .Filterable() // here's the filterable option
    .Selectable()
    .Events(e => e.Change("onChange"))
    .Pageable(pageable => pageable
        .Refresh(true))
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(15)
        .Read(read => read.Action("GetConcessions", "MasterData"))
    )
    )
</div>

The grid renders perfectly and now little filter icons show on the grid's column headers:

But when I click one, the popup opens for a half second and the error is thrown. I'm using Visual Studio 2010 and the debugger shows a popup with javascript runtime error: object doesn't support property or method 'addBack'.

Also, it opens the file kendo.all.min.js with an highlight on a line of code where a method addBack is.

NOTE: I've tested on Chrome and Firefox and it works fine. The issue only exists when using Internet Explorer (version 11).

Any help?

解决方案

Make sure you have Jquery-1.8.1.min.js or higher version of jquery in your page.Because addBack is added in 1.8.

Try like this,

 @(Html.Kendo().Grid<SustIMS.Models.ConcessionModel>()
    .Name("datagrid_Concessions")
    .Columns(columns =>
    {
        columns.Bound(c => c.Code).Title("Code");
        columns.Bound(c => c.Description).Title("Description");
        columns.Bound(c => c.TrafficOpeningDate).Title("Traffic Opening Date");
        columns.Bound(c => c.CreationDate).Title("Creation Date");
    })
    .HtmlAttributes(new { style = "height: 534px;" })
    .Filterable() // here's the filterable option
    .Selectable()
    .Events(e => e.Change("onChange"))
    .Pageable(pageable => pageable
        .Refresh(true))
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(15)
        .Model(model =>     <--- Add this
         {
           model.Id(m => m.Id);
           model.Field(m => m.Code);
           model.Field(m => m.Description);
         })
        .Read(read => read.Action("GetConcessions", "MasterData"))
    )
    )

See this DEMO : http://jsbin.com/emuqazEz/4/edit

这篇关于Javascript 运行时错误:“对象不支持属性或方法"在 Internet Explorer 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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