On a grid, is it possible to change the default filter method for a string type column? To me, "contains" makes more sense than "is equal", as it will be used more often.
We've tried to change it on the columnMenuInit event, but on the first attempt to filter, the DropDownList is reset to the "is equal" option.
Thanks!
12 Answers, 1 is accepted
You can change the order in which the filter operators are defined for string type. This will affect the default/first filter option in the menu. Here is an example for this: http://jsbin.com/ulerib/2/edit
Regards,Nikolay Rusev
the Telerik team


Please check the example below:
.Filterable(f =>
f.Operators(o =>
o.ForDate(d => d
.Clear()
.IsLessThanOrEqualTo(
"Less Than Or Equal To"
)
.IsGreaterThanOrEqualTo(
"Greater Than Or Equal To"
)
.IsLessThan(
"Less Than"
)
.IsGreaterThan(
"Greater Than"
)
.IsNotEqualTo(
"Not Equal To"
)
.IsEqualTo(
"Equal To"
)
)
)
)
Vladimir Iliev
Telerik

Basically this feature is not supported out-of-the-box and it will require custom solution. For example you can modify the Grid prototype options object - that way the grid will be initialized with different default options.
e.g.:
//you can execute that just after kendo.all/web script
kendo.ui.Grid.prototype.options.filterable =
true
;
Vladimir Iliev
Telerik

I have updated the jsbin provided by Nikolay by adding a default filter on the datasource :
filter: {field:"foo", operator:"eq", value:"foo"}
It works as the filter is applied by default however the filter icon is not activated on the column..
Any idea of a workaround ?
Thanks!
This will work if you upgrade to latest version of Kendo UI.
http://jsbin.com/ulerib/15/edit
Nikolay Rusev
Telerik

If I exclude "IsEqualTo" then the grid filter options render in the order I specify. As soon as I put IsEqualTo back in again, it defaults and ignores whatever I specified.
This works as expected.
.Filterable(f => f.Messages(m => m.IsFalse("No")).Messages(m => m.IsTrue("Yes"))
.Operators(
o => o
.ForString(s =>
s.Clear()
.Contains("Contains")
.DoesNotContain("Does not contain")
//.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.StartsWith("Starts with")
.EndsWith("Ends with")
)
))
This defaults back to KendoUI defaults and ignores my code.
.Filterable(f => f.Messages(m => m.IsFalse("No")).Messages(m => m.IsTrue("Yes"))
.Operators(
o => o
.ForString(s =>
s.Clear()
.Contains("Contains")
.DoesNotContain("Does not contain")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
.StartsWith("Starts with")
.EndsWith("Ends with")
)
))
The reason for current behavior is that the Grid internally exports filter settings only if the collection of filters have different count than the default filters collection or at least one filter have different text. That why in current case I would suggest to simply add one empty space to the end of one of the messages as follows:
.Filterable(f => f.Messages(m => m.IsFalse(
"No"
)).Messages(m => m.IsTrue(
"Yes"
))
.Operators(
o => o
.ForString(s =>
s.Clear()
.Contains(
"Contains"
)
.DoesNotContain(
"Does not contain"
)
.IsEqualTo(
"Is equal to"
)
.IsNotEqualTo(
"Is not equal to"
)
.StartsWith(
"Starts with"
)
.EndsWith(
"Ends with "
)
)
))
Regards,
Vladimir Iliev
Telerik

This forces us to set the message for each operator. But we are using kendo.messages.fr-FR.js
So now we have to set the proper french message for each operator in each grid... this is a major maintenance issue.
Is there any way doing this without override messages?
Thanks
Currently there is no other way other than overriding the messages as demonstrated in the following example:
Regards,
Vladimir Iliev
Telerik