【发布时间】:2014-06-26 16:35:36
【问题描述】:
是否可以有一个过滤器菜单,其中包含是、否、其他等选项
我有一个网格,其中有一列只能包含 3 个值 Yes、No 或 Other。过滤器应该显示带有这些值的单选按钮和两个按钮过滤器和清除。这可能吗?
当我尝试使用字段类型:“布尔”时,我得到“是”和“否”,但如何添加第三个单选按钮“其他”。
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: kendo-ui
是否可以有一个过滤器菜单,其中包含是、否、其他等选项
我有一个网格,其中有一列只能包含 3 个值 Yes、No 或 Other。过滤器应该显示带有这些值的单选按钮和两个按钮过滤器和清除。这可能吗?
当我尝试使用字段类型:“布尔”时,我得到“是”和“否”,但如何添加第三个单选按钮“其他”。
任何帮助将不胜感激。
谢谢
【问题讨论】:
标签: kendo-ui
剑道在这里有一个如何做到这一点的例子:
http://demos.telerik.com/kendo-ui/grid/filter-menu-customization
这是一个示例,说明您的过滤器可能会如何设置
filterable: {
//hide second filter option
extra: false,
operators: {
string: {
eq: "Is equal to"
}
}
},
filterMenuInit: function(e) {
//when the filter menu opens find the first dropdown and hide it
//as it has the Is equal to filter in it.
e.container.find(".k-dropdown").eq(0).hide();
}
这里是展示如何使用其中一些功能的 JSbin: http://jsbin.com/qehugexo/2/edit
可以用这样的代码来完成:
$(".k-grid").data("kendoGrid").dataSource.filter({filters: [{field: "City", operator: "eq", value: "Boston"}], Logic: "and"})
这是一个如何使用它的示例。
filterMenuInit: function(e) {
//when filter menu opens toss it cause its lame!
e.container.html("
<input name='radio' type='radio' checked='checked' value='Clear'>Clear</input>
<input name='radio' type='radio' value='London'>London</input>
<input name='radio' type='radio' value='Seattle'>Seattle</input>
");
$("input[type=radio]").click(function(){
if($(this).val() != "Clear") {
$(".k-grid").data("kendoGrid").dataSource.filter({filters: [{field: "City", operator: "eq", value: $(this).val()}], Logic: "and"})
}else {
$(".k-grid").data("kendoGrid").dataSource.filter({})
}
});
}
还有一个更新的 JSbin:http://jsbin.com/qehugexo/3/edit
【讨论】: