Search code examples
asp.net-mvcgridkendo-ui

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


Solution

  • 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