简体   繁体   English

Kendo UI网格扩展了过滤器参数

[英]Kendo UI Grid extending the filter parameter

To set the default filter operators for my columns I have been using: 要为我的列设置默认的过滤器运算符,我一直在使用:

filterMenuInit: function(e) {
            if (e.field == "name") {
                var firstValueDropDown = e.container.find("select:eq(0)").data("kendoDropDownList");
                firstValueDropDown.value("contains");
                firstValueDropDown.trigger("change");

                var logicDropDown = e.container.find("select:eq(1)").data("kendoDropDownList");
                logicDropDown.value("or");
                logicDropDown.trigger("change");

                var secondValueDropDown = e.container.find("select:eq(2)").data("kendoDropDownList");
                secondValueDropDown.value("contains");
                secondValueDropDown.trigger("change");
            }
...
}

But I would like to be able to do something like this: 但我希望能够做这样的事情:

filterable: {
    extra: true,
    defaultStringOperator: 'contains',
    defaultNumberOperator: 'gte'
}

How do I extend or alter Kendo UI grid to implement this? 如何扩展或更改Kendo UI网格以实现此目的?

The way I handle this is to explicitly set the filterable object on my grids with each type and their respective operators as they will get added in order. 我处理此问题的方法是在网格上显式设置每种类型及其各自的运算符的可过滤对象,因为它们将按顺序添加。 It was requested that Contains be the default when the column data type is a string. 当列数据类型为字符串时,要求将Contains作为默认值。

filterable: {
operators: { 
  string: { contains: 'Contains', doesnotcontain: 'Does not contain', eq: 'Is equal to', neq: 'In not equal to', startswith: 'Starts with', endswith: 'Ends with' }, 
  number: { gte: 'Greater Than or Equals and stuff', eq: 'Equal To', neq: 'Not Equal To', gt: 'Greater Than'  } 
}


}

Sample... http://jsbin.com/diyivu/1/edit 范例... http://jsbin.com/diyivu/1/edit

I also added number and some operators for it, you would continue with datetime and boolean if needed. 我还添加了数字和一些运算符,如果需要,您将继续使用datetime和boolean。 Documentation for filterable.operators http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-filterable.operators filterable.operators的文档http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-filterable.operators

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM