Kendo UI Grid ASP.NET MVC - UI怪异
问题描述:
嗯,我在ASP.NET MVC应用程序中使用Kendo UI网格。我的目标是去除的过滤嘴的一些项目当一个特定的JavaScript事件是由另一过滤器B.Kendo UI Grid ASP.NET MVC - UI怪异
所以,我已经开始与设置自定义UI我列的CategoryId提出:
@(Html.Kendo().Grid(Model.Items)
.Name("grid")
.Columns(columns =>
{
....
columns.ForeignKey(p => p.CategoryId, Model.Categories, "CategoryId", "CategoryName")
.Filterable(filterable => filterable.UI("categoryFilter")));
....
}
某处以上之前,我定义我的JavaScript UI功能:
function categoryFilter(element) {
console.log('Kendo UI will never run me '); // Unreachable part
element.kendoAutoComplete({
dataSource: customDataSource,
optionLabel: "--Select Value--"
});
}
剑道电网从来没有通话功能categoryFilter
,仍然是一个错误是由剑道提出时,我尝试使用无效的函数名称,例如:
....
// Kendo raise an error here
.Filterable(filterable => filterable.UI("functionWitchDoesntExist")));
....
问题:我错过了什么让我的UI过滤器工作?
我的问题的另一种解决方案是,如果我可以通过jQuery获取现有的过滤器。喜欢的东西:
$('#grid').find('.kendoautocompletefilter').options('.....')
答
您可以使用数据绑定事件:
Events(Function(o) o.DataBound("YourFunction")
,并添加或删除的javascript过滤:
YourFunction function (yourValues)
{
var filter = {
logic: "or",
filters: []
};
filter.filters.push(
{ field: "Status", operator: "contains", value: yourValues },
{ field: "PriorityLevelDisplayText", operator: "or", value: yourValues},
);
myGrid.dataSource.filter([filter]);
};
好像自定义过滤器不适合对外关键列。请与telerik团队核对。 – Andrea 2015-02-10 18:13:22
你可能想尝试把'categoryFilter' JS函数放在你的网格定义之上。不知道这是否是问题,只是一个想法。 – 2015-02-11 15:39:05
@ mmillican56:谢谢您的评论。实际上它已经超出了网格定义。 – Ksv3n 2015-02-11 16:37:03