3

我现在正在尝试使用带有一些虚拟数据的下拉框来实现自定义过滤器 UI。我已经按照剑道网站(http: //demos.kendoui.c​​om/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>" : "" #', 
        }, 
...

当我单击过滤器时,我得到的只是标准的“开头”和文本输入。

我错过了什么?

4

1 回答 1

5

自定义过滤 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

于 2013-02-25T15:12:57.537 回答