Change default Filter Operator

Hey Guys,

I tried to change the Default Filter Operator in my Grid, using the normal filter Menu.

I saw this solution in the Web:
https://www.syncfusion.com/kb/7549/how-to-change-the-default-filter-operator-type-to-contains-in-filter-menu

also, i tried to do a combination with this for the filter bar:
https://www.syncfusion.com/kb/3369/how-to-change-the-default-comparison-operator-of-the-filter-bar

but these solutions aren't working for me.

Is there another easy solution?

Thanks for your help.

Kindly regards Dominic

5 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team September 30, 2020 11:54 AM UTC

Hi Dominic, 

Greetings from Syncfusion support. 

Based on your requirement, you need to change the filter operator for the particular column in EJ2 Grid. 
 
You can achieve your requirement by using the filter property of the column. Refer to the below code example and sample for more information. 


<e-grid-column field="CustomerID" headerText="Customer ID" filter=@(new { @operator="contains"}) width="120"></e-grid-column> 



Please get back to us if you need further assistance with this. 

Regards, 
Rajapandiyan S 



DB Dominic Buerki September 30, 2020 12:01 PM UTC

Thanks for your input, but im using this notation:

@Html.EJS().Grid(ViewData[ViewDataKeys.GridId] as string).AllowResizing().DataSource(ds =>
       {
           ds.Url(Url.Action("GetOrganizations", "Organization", new { area = "Admin" }));
           ds.Adaptor("UrlAdaptor");
       }).AllowSorting().SortSettings(sort =>
       {
           sort.Columns(new List { new { field = "ValidUntil", direction = "Ascending" } });
       }).AllowFiltering().FilterSettings(filter => filter.Type(FilterType.Menu)).AllowPaging().PageSettings(page =>
       {
           page.PageSize(25);
           page.PageSizes(new List { 25, 50, 100 });
           page.PageCount(3);
       }).Columns(col =>
       {
.
.
.
}).Render()

how can i implement this here?

Thanks




RS Rajapandiyan Settu Syncfusion Team October 1, 2020 01:26 PM UTC

Hi Dominic, 

Thanks for your update. 

Based on your requirement, we have created the EJ2 Grid using @Html tagHelper and bind the filter property to a column as below. 


@{ 
    List<object> cols = new List<object>(); 
    cols.Add(new { field = "CustomerID", direction = "Ascending" }); 
} 
 
@Html.EJS().Grid("Grid").AllowResizing().DataSource(ds => 
{ 
    ds.Url(Url.Action("UrlDatasource", "Home")); 
    ds.Adaptor("UrlAdaptor"); 
}).AllowSorting().SortSettings(sort => sort.Columns(cols)).AllowFiltering().FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu); }).AllowPaging().PageSettings(page=> { page.PageSizes(true); }).Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); 
    col.Field("ShipCountry").HeaderText("Ship Country").Filter(new { @operator = "contains" }).Width("120").Add(); 
 
}).Render() 



Please get back to us if you need further assistance with this. 

Regards, 
Rajapandiyan S

Marked as answer

DB Dominic Buerki October 5, 2020 06:16 AM UTC

Thank you very much für your help!
I could have seen this by myself, but thanks for taking your time and show me how to do this.

Best Regards
Dominic


RS Rajapandiyan Settu Syncfusion Team October 6, 2020 04:44 PM UTC

Hi Dominic, 
 
We are glad that the provided solution is resolved your problem. 
 
Please get back to us if you need further assistance with us. 
 
Regards, 
Rajapandiyan S 


Loader.
Up arrow icon