imperium2335
imperium2335

Reputation: 24112

Kendo UI Grid extending the filter parameter

To set the default filter operators for my columns I have been using:

filterMenuInit: function(e) {
            if (e.field == "name") {
                var firstValueDropDown = e.container.find("select:eq(0)").data("kendoDropDownList");
                firstValueDropDown.value("contains");
                firstValueDropDown.trigger("change");

                var logicDropDown = e.container.find("select:eq(1)").data("kendoDropDownList");
                logicDropDown.value("or");
                logicDropDown.trigger("change");

                var secondValueDropDown = e.container.find("select:eq(2)").data("kendoDropDownList");
                secondValueDropDown.value("contains");
                secondValueDropDown.trigger("change");
            }
...
}

But I would like to be able to do something like this:

filterable: {
    extra: true,
    defaultStringOperator: 'contains',
    defaultNumberOperator: 'gte'
}

How do I extend or alter Kendo UI grid to implement this?

Upvotes: 1

Views: 937

Answers (1)

Robin Giltner
Robin Giltner

Reputation: 3055

The way I handle this is to explicitly set the filterable object on my grids with each type and their respective operators as they will get added in order. It was requested that Contains be the default when the column data type is a string.

filterable: {
operators: { 
  string: { contains: 'Contains', doesnotcontain: 'Does not contain', eq: 'Is equal to', neq: 'In not equal to', startswith: 'Starts with', endswith: 'Ends with' }, 
  number: { gte: 'Greater Than or Equals and stuff', eq: 'Equal To', neq: 'Not Equal To', gt: 'Greater Than'  } 
}


}

Sample... http://jsbin.com/diyivu/1/edit

I also added number and some operators for it, you would continue with datetime and boolean if needed. Documentation for filterable.operators http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-filterable.operators

Upvotes: 1

Related Questions