Kendo Grid MVC Change Filter Operator

1 Answer 508 Views
Filter Grid
Herve
Top achievements
Rank 1
Herve asked on 03 Feb 2022, 02:29 PM

Hello,

I'm working in a project in which all the Kendo Components are used in the UI.
We need, due to a client request, to change the chosen default option in the filters of ALL THE GRIDS.
To explain a little bit more, we need to pass from "Is equal" (Please see the picture attached)  to "contains" when we filter a column.

I know we can customize the filter operators and options for a particular grid, but in this case we want to apply the change in ALL THE GRIDS without update the options to each.

Hope I was clear when I explained the need.
Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 08 Feb 2022, 08:17 AM

Hello,

There is no API method for changing a default option in all components, so achieving this would require modifying the source code of the Grid. 

Apart from such modifications, the available approach for setting the default filter option in a specific Grid, is to use its FilterMenuInit event:

function onFilterMenuInit(e) {
  // check if the Filter menu is initialized for the "ShipName" column:
  if (e.field == "ShipName") {
    var firstValueDropDown = e.container.find('[data-bind="value: filters[0].operator"]').data('kendoDropDownList');
    firstValueDropDown.value("contains");
    firstValueDropDown.trigger("change");

    var secondValueDropDown = e.container.find('[data-bind="value: filters[1].operator"]').data('kendoDropDownList');
    secondValueDropDown.value("contains");
    secondValueDropDown.trigger("change");
  }
}

 

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Filter Grid
Asked by
Herve
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or