Search code examples
filterextjsgrid

ExtJS 7.6 : 'not like' filter operator for a gridcolumn


I saw in sencha source code that an operator 'not like' exists for filter bar of a grid. So i tried to use it by defining it on some of my columns of my grid. I can see this new operator but it doesn't work.

I defined this operator like this on some of my columns:

  column.filter = {
    type: 'string',
    operators: ['like', 'nlike', 'empty', 'nempty']
  };

And it 'works'. I can see this new operator on my column (i overrided the icons with scss and the associated label):

enter image description here

But it doesn't work when i try to use it. Apparently there is no filterFn associated to this standard operator.

Someone tried and succeeded in using this string operator?


Solution

  • I found a workaround to this issue. Apparently extjs has forgot to implement the not like operator even if this one is declared...

    Here is the override that works for me:

    Ext.define('myapp.overrides.util.Filter', {
      override: 'Ext.util.Filter'
    }, function() {
      var prototype = this.prototype,
          operatorFns = prototype.operatorFns;
      operatorFns.nlike = function(candidate) {
        var v = this._filterValue;
        return !(v && this.getCandidateValue(candidate, v).toLowerCase().indexOf(v.toLowerCase()) > -1);
      }
    });