View Full Version : Listfilter with custom operator

23 Sep 2013, 3:11 AM
I would like to implement a listfilter in my gridpanel with does not use an "equal"-operator but a "less-than"-operator.
This is because I have a list of distances in the filter which are the maximum distances to be filtered.

My listfilter has the following entries:

< 5 km
< 10 km
< 25 km
< 50 km
< 100 km
< 200 km

So if I filter a column for < 25 km I want to have all items less than 25 km.

Thanks in advance.

23 Sep 2013, 7:19 AM
just extend ListFilter and override the validateRecord method (aka replace the return statement with your condition to return true or false from the method

* Template method that is to validate the provided Ext.data.Record
* against the filters configuration. * @param {Ext.data.Record} record The record to validate
* @return {Boolean} true if the record is valid within the bounds
* of the filter, false otherwise.
validateRecord: function (record) {
var valuesArray = this.getValue();
return Ext.Array.indexOf(valuesArray, record.get(this.dataIndex)) > -1;