我现在正在尝试使用带有一些虚拟数据的下拉框来实现自定义过滤器 UI。我已经按照 Kendo 网站 ( http://demos.kendoui.com/web/grid/filter-menu-customization.html ) 上的教程进行操作,但它对我不起作用:(。
这是自定义 UI 的函数:
function relStatFilter(element)
{
element.kendoDropDownList({
dataSource: ["Prospect", "Customer"],
optionLabel: 'Select status'
})
}
下面是应用它的列参数:
...
{
field: 'relStat',
filterable:
{
ui: relStatFilter,
extra: false
},
title: '<abbr title=\'Relationship status\'>Rel stat</abbr>',
template: '#= ratio == 0 ? "<span class=text-info>Prospect</span>" : relStat == "Active" ? "<span class=text-success>Active</span>" : relStat == "At risk" ? "<span class=text-warning>At risk</span>" : "" #',
},
...
当我点击过滤器时,我得到的只是标准的“开头为”和文本输入。
我错过了什么?
最佳答案
自定义筛选 UI 自 2012.3.1315 起可用。确保您使用的不是旧版本。使用 2012.3.1315 以下代码按预期工作:
$("#grid").kendoGrid({
dataSource: [ { name: "Foo" }, { name: "Bar" }],
filterable: {
extra: false,
operators: {
string: {
eq: "Is equal to",
neq: "Is not equal to"
}
}
},
columns: [
{
field: "name",
filterable: {
ui: function(element) {
element.kendoDropDownList({
dataSource: [ "Foo", "Bar"]
});
}
}
}
]
});
这是一个现场演示:http://jsbin.com/uwiqow/1/edit
关于javascript - Kendo UI 网格自定义过滤器 UI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15061501/