New to Kendo UI for jQuery? Download free 30-day trial

Setting a Default Filter Operator in Kendo UI for jQuery Grid with Column Menu

Description

When configuring the Kendo UI for jQuery Grid with the column menu filter mode, you might want to set a default filter operator for a specific column. For example, setting the default operator to "not equal to" for a string column. This knowledge base article also answers the following questions:

  • How can I change the default filter operator in the Kendo UI for jQuery Grid?
  • Is there a way to specify a default filter condition for columns in the Grid?
  • Can I set a default filter operator for a Grid column using the column menu?

Environment

Product Kendo UI for jQuery Grid

Solution

To change the default filter operator for a column in the Kendo UI for jQuery Grid with a "columnMenu" of "tabbed" and "filterable" mode set to "menu", utilize the columnMenuInit event. This event allows you to access and modify the dropdown list for the filter menu, thereby setting a new default operator.

Here is how you can achieve this:

  1. Bind to the Grid's columnMenuInit event.

  2. Within the event handler, check the field for which the column menu is initialized.

  3. Find the DropDownList component in the e.container element.

  4. Set the desired value (operator) for the DropDownList and trigger a change event.

Below is a code example that demonstrates how to set the default operator to "not equal" ("neq") for a column with the field name "name".

columnMenuInit:function(e){
  if(e.field === "name"){
    var ddl = e.container.find("[data-role='dropdownlist']").data("kendoDropDownList"); 
    ddl.value("neq");
    ddl.trigger("change");
  }
},

For a practical implementation, refer to this example.

See Also

In this article