FilterSettings Operator contains

Hi, 
I need to change the "startswith" operator filter into "contains" for my filter bar in my grid

This is my code

@{
    object op = new {@operator = "contains" };
}
<ejs-grid id="Grid" dataSource="@ViewBag.source" allowFiltering="true" allowPaging="true" allowSelection="false">
    <e-grid-filterSettings operators="@op"></e-grid-filterSettings>
    [...]

</ejs-grid>

But it doesn't work.
How can I fix?

Thanks

1 Reply

HJ Hariharan J V Syncfusion Team September 18, 2018 12:36 PM UTC

Hi Mini, 

Thanks for contacting Syncfusion support. 

Query: I need to change the "startswith" operator filter into "contains" for my filter bar in my grid 

We have analyzed your query and we suggest to use actionBegin event of the grid. To achieve your requirement, we have changed the filter operator to “contains” in the actionBegin event function. Please refer to the below sample and documentation for your reference. 

Code Example: 

[.cshtml] 
<div> 
    <ejs-grid id="Grid" dataSource="ViewBag.DataSource" actionBegin="actionBegin" allowFiltering="true" allowPaging="true" toolbar="@(new List<string>() {"Add", "Edit", "Delete", "Cancel", "Update"})"> 
        <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Normal"></e-grid-editSettings> 
        <e-grid-columns> 
            ... 
       </e-grid-columns> 
 
    </ejs-grid> 
</div> 
 
<script> 
    function actionBegin(args) { 
        if (args.requestType == "filtering") { 
            var len = this.filterSettings.columns.length; 
            for (var i = 0; i < len; i++) { 
                this.filterSettings.columns[i].operator = "contains"; 
            } 
        } 
    } 
</script> 



Please get back to us for further assistance. 

Regards,  
Hariharan 


Loader.
Up arrow icon