[英]Kendo UI Grid extending the filter parameter
要为我的列设置默认的过滤器运算符,我一直在使用:
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");
}
...
}
但我希望能够做这样的事情:
filterable: {
extra: true,
defaultStringOperator: 'contains',
defaultNumberOperator: 'gte'
}
如何扩展或更改Kendo UI网格以实现此目的?
我处理此问题的方法是在网格上显式设置每种类型及其各自的运算符的可过滤对象,因为它们将按顺序添加。 当列数据类型为字符串时,要求将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' }
}
}
范例... http://jsbin.com/diyivu/1/edit
我还添加了数字和一些运算符,如果需要,您将继续使用datetime和boolean。 filterable.operators的文档http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-filterable.operators
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.