I have a Kendo UI grid that is rendered with javaScript. I want the string columns to have a single option ("Contains") and without the second filter. So far so good, I wrote
$("#MyGrid").kendoGrid({
// other bits of configuration here
filterable: {
extra:false,
operators: {
string:{ contains: "Contains"}
}
},
// more bits of configuration here
});
As part of the definition of the grid. And the result looks good-ish (I only have one option, so the drop down is redundant).
However, regardless of this, the filter still performs the equals operation rather than the contains operation (which is the only one available to it).
I've spent a while trying to figure this out and I keep going around in circles because the code I found either does not work, or doesn't make sense, or both.
Can anyone tell me how to default the filter to "Contains" and not "Is Equal To"?
When you only have a single option or you are not happy with the layout you can completely customize the filter control using the "ui : func( element ) { }" overload which is present in the later versions of Kendo (e.g. v2013.1.319)
Here is the function that then customizes the look:
Here is an example of having two date boxes with GTE/LTE format:
Obviously you can template out however you like and create different custom filters for Date, Boolean, etc -- note that for the Date version above if you want to set the operators correctly to say "gte" and "lte" for filter[0].operator and filter[1].operator you can just set that on the dataSource.filter attribute like so:
I had the same problem and I got it, that it needs the .Clear() option!
I am building my Grid with the MVC Wrapper in Razor:
Summary:
.Contains()
first after.Clear()
then the default is Contains!Additional Info: I am using Kendo UI 2013.1.514
filterable: { operators: { number: { gte: "greater than or equal to" } } }
Try to update to latest internal build. Version later than 2012.3.1304 should contain the fix.
The best way to change the default operator for all of the instances:
and the complete script: