如何使用Razor在Telerik MVC3网格中设置并选择高级过滤器选项?
- 内容介绍
- 文章标签
- 相关推荐
本文共计321个文字,预计阅读时间需要2分钟。
我在学习Telerik MVC3进行扩展,特别之处在于它支持网格,可以看到here,我正在使用自定义分页,并对过滤选项感兴趣。使用以下内容很容易允许每列过滤:.Columns(x=> x.Bound(col=> col.Id)).Filterable(false)。
我正在玩Telerik MVC3扩展,特别是网格,可以看到 here我正在使用自定义分页,并对围绕过滤的选项感兴趣.
使用以下内容很容易允许每列过滤:
.Columns(x => { x.Bound(col => col.Id).Filterable(false);
但是,当我启用它时,似乎我无法选择向用户显示哪些选项.无论在哪个领域,我都会在过滤器下拉列表中获得以下内容:
理想情况下,我只想要’包含’ – 这可能吗?
我的解决方案是这样的:Telerik GRID代码:
columns.Bound(o => o.MRUCode).HeaderHtmlAttributes(new { @class = "FilterOnlyOn_Contains" });
JavaScript代码:
$(".FilterOnlyOn_Contains .t-filter").click(function () { setTimeout(function () { // Remove all existing options and add 'Contains' var filterOptions1 = $(".t-filter-operator").first(); filterOptions1.empty(); filterOptions1.append($("<option />").val("substringof").text("Contains")); // Remove second part (options + text + input) var filterOptions2 = $(".t-filter-operator").last(); filterOptions2.hide(); $(".t-filter-help-text").text(""); $("input[type=text]").last().hide(); }); });
结果如下:
本文共计321个文字,预计阅读时间需要2分钟。
我在学习Telerik MVC3进行扩展,特别之处在于它支持网格,可以看到here,我正在使用自定义分页,并对过滤选项感兴趣。使用以下内容很容易允许每列过滤:.Columns(x=> x.Bound(col=> col.Id)).Filterable(false)。
我正在玩Telerik MVC3扩展,特别是网格,可以看到 here我正在使用自定义分页,并对围绕过滤的选项感兴趣.
使用以下内容很容易允许每列过滤:
.Columns(x => { x.Bound(col => col.Id).Filterable(false);
但是,当我启用它时,似乎我无法选择向用户显示哪些选项.无论在哪个领域,我都会在过滤器下拉列表中获得以下内容:
理想情况下,我只想要’包含’ – 这可能吗?
我的解决方案是这样的:Telerik GRID代码:
columns.Bound(o => o.MRUCode).HeaderHtmlAttributes(new { @class = "FilterOnlyOn_Contains" });
JavaScript代码:
$(".FilterOnlyOn_Contains .t-filter").click(function () { setTimeout(function () { // Remove all existing options and add 'Contains' var filterOptions1 = $(".t-filter-operator").first(); filterOptions1.empty(); filterOptions1.append($("<option />").val("substringof").text("Contains")); // Remove second part (options + text + input) var filterOptions2 = $(".t-filter-operator").last(); filterOptions2.hide(); $(".t-filter-help-text").text(""); $("input[type=text]").last().hide(); }); });
结果如下:

