【问题标题】:KendoUI Grid Custom Filter UIKendoUI 网格自定义过滤器 UI
【发布时间】:2013-02-25 06:47:56
【问题描述】:

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

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

我错过了什么?

【问题讨论】:

    标签: javascript jquery kendo-ui kendo-grid


    【解决方案1】:

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

    【讨论】:

    • 谢谢,我找不到下载那个版本的地方,但我只是拿了他们在示例中使用的代码,它运行良好。
    猜你喜欢
    • 2022-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    • 1970-01-01
    • 2015-03-29
    • 1970-01-01
    • 2023-03-19
    相关资源
    最近更新 更多