我正在使用剑道网格,它们对于 CRUD 操作运行良好。现在,我想通过向网格规范添加 .Filterable()
选项来添加过滤。这是一些代码:
<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>
网格呈现完美,现在网格的列标题上显示小过滤器图标:
但是当我单击一个时,弹出窗口会打开半秒并引发错误。我正在使用 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<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"))
)
)
关于JavaScript 运行时错误 : "object doesn' t support property or method"in Internet Explorer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24883572/