Cant filter grid column with operator 'contains' through filterbar

Hello,
I'm trying to set column filter operator to contains but it only works in initial load filtering. I mean if I configure filterOptions like this
this.filterOptions = {
mode: 'Immediate',
immediateModeDelay: 500,
columns: [
{ field: 'name', matchCase: false, operator: 'contains', predicate: 'and', value: 'iciar' }
]
};
It works at initial load. But I don't want to filter on initial load, I only need to set the default filter operator to 'contains' in this column.
Thanks in advance.

3 Replies

HJ Hariharan J V Syncfusion Team August 9, 2018 11:41 AM UTC

Hi Martin, 
 
Thanks for contacting Syncfusion support. 
 
Query: I'm trying to set column filter operator to contains but it only works in initial load filtering. It works at initial load. But I don't want to filter on initial load, I only need to set the default filter operator to 'contains' in this column. 
 
We have validated your query and you can achieve your requirement by using the below method. By default, the string column will have “startsWith” as the default filer operator and the integer columns will have the “equal” as default filter operator. For your requirement, we suggest you to set the “contains” operator for the string columns by using the ‘actionBegin’ event of Grid. Please refer the below code example for your reference. 
 
[code example] 
[hierarchy.html]  
 <ejs-grid #Grid id='Grid' [dataSource]='parentData' allowFiltering=true (actionBegin)=begin($event) height=300 > 
        <e-columns> 
            ... 
            <e-column field='CustomerID' headerText='Name' width='140'></e-column> //CustomerID is the string column 
        </e-columns> 
    </ejs-grid> 
 
[hierarchy.component.ts] 
 
    public begin(args:any):void{ 
        if(args.requestType == "filtering" && args.currentFilteringColumn == "CustomerID") {  
              args.columns.forEach(col => {   
                if(col.field == 'CustomerID') {   
                    col.operator = 'contains';       // set the “contains” operator for the ‘CustomerID’ column  
                }   
             });   
        }  
    } 
 
We have prepared a simple sample based on your requirement. Please find the sample in below link. 
 


Please get back to us if you need further assistance on this. 
 
Regards, 
Hariharan 



MA Martin August 10, 2018 07:48 AM UTC

Thank you very much for your response.
It works as expected.
Best regards.


HJ Hariharan J V Syncfusion Team August 13, 2018 07:11 AM UTC

Hi Martin,  
  
Thanks for the feedback.  
 
We are very happy to hear that your issue is resolved. Please let us know if you have any further assistance on this.  
   
Regards,  
Hariharan 


Loader.
Up arrow icon