Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the default filter operator in kendo ui grid mvc

I have managed to change the default filter order for the Kendo Grid using:

.Filterable(filterable => filterable
                        .Extra(true)
                        .Operators(ops => 
                            ops.ForString(str => str.Clear()
                                                    .Contains("Contains")
                                                    .StartsWith("Starts with")
                                                    .EndsWith("Ends with")
                                                    .IsEqualTo("Is equal to"))
                        ))

Is there any way I can change the default operator to OR?

enter image description here

like image 524
GerardBeckerleg Avatar asked Sep 25 '13 06:09

GerardBeckerleg


People also ask

How do I set the default filter in kendo grid?

Solution. On the dataBound event of the grid, find the filter dropdown and select() the desired default filter option. On the filter event of the Grid, if the filter is cleared, select the desired default filter option.

What is dataItem in kendo grid?

Returns the data item to which the specified table row is bound. The data item is a Kendo UI Model instance. When using the Grid's MVC wrapper, the Grid must be Ajax-bound for the dataItem() method to work.

What is Pageable in kendo grid?

pageable Boolean|Object (default: false) If set to true the grid will display a pager. By default paging is disabled. Can be set to a JavaScript object which represents the pager configuration. Don't forget to set a pageSize, no matter if paging is performed client-side or server-side.


1 Answers

This can be done via the filterMenuInit event:

 /* grid configuration snip */
.Events(e => e.FilterMenuInit("filterMenuInit"))
 /* grid configuration snip */

 <script>
 function filterMenuInit(e) {
      e.container
         .find("select.k-filter-and")
         .data("kendoDropDownList")
         .value("or");
 }
 </script>

Here is a live demo: http://jsbin.com/etItEpi/1/edit

like image 187
Atanas Korchev Avatar answered Sep 16 '22 13:09

Atanas Korchev