Custom Filter Operator

Hey!

I have:

  • Bar Filter
  • Column with type 'object'
  • And custom 'change' function that calls filterByColumn

Is there a way to define 'custom' operator that I can use in filterByColumn

gridObj.filterByColumn(columnName, 'custom', true);

Where I can define a custom function linked to this operator - so I can filter my very specific objec


1 Reply

DM Dineshnarasimman Muthu Syncfusion Team September 9, 2024 02:20 PM UTC

Hi Iana Stapelberg,


Greetings from Syncfusion Support.


We have reviewed your query and understood that you expect to filter the grid column with custom operator. We also noticed that you have set the grid column type as 'object'. We would like to tell you that the Grid doesn't support the column.type as object. We have attached the types which the grid support for the grid columns for your reference.


Column Type: https://ej2.syncfusion.com/angular/documentation/grid/columns/columns#column-types


To filter the grid with custom filter operator, we suggest you to use grid.filterSettings.column and provide proper filter predicates. We have attached the code information implementing the custom operator for 'between'.


 filter() {

    var predicates = [

      {

        field: 'Freight',

        operator: 'greaterthan',

        condition: 'or',

        value: 10,

      },

      {

        field: 'Freight',

        operator: 'lessthan',

        condition: 'and',

        value: 20,

      },

    ];

    this.grid.filterSettings.columns = predicates.map((predicate=> {

      return {

        field: predicate.field,

        operator: predicate.operator,

        value: predicate.value,

        predicate: predicate.condition,

      };

    });

  }

 


Sample: https://stackblitz.com/edit/angular-imtnt6?file=src%2Fapp.component.ts


If this doesn't meet your requirement, please elaborate your requirement so that we can understand better and provide appropriate solution.


Regards,

Dineshnarasimman M


Loader.
Up arrow icon