Examples on how to use GridFilterSettings.Operators?

I'd like to control which filter operators available for columns in my DataGrid. I've seen the GridFilterSettings.Operators property but it's not clear how to set this. Are there any examples available that show how to use this?

5 Replies

JP Jeevakanth Palaniappan Syncfusion Team March 18, 2021 06:07 AM UTC

Hi Dario, 

Greetings from Syncfusion support. 

We have validated your query and we suspect that you want to override the default operator for grid columns. Please find the below documentation for your reference. 


Get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



DA Dario March 18, 2021 06:57 AM UTC

Hi Jeevakanth SP

Thanks for the reply.

I'm familiar with the document links you've sent. I can change the default operator for a column, but I'm trying to control the available operators for a column (e.g. I don't want users to use the not equal operator).

The documentation here describes the GridFilterSettings.Operators property saying "The Operators is used to override the default operators in filter menu. This should be defined by type wise (string, number, date and boolean). Based on the column type, this customize operator list will render in filter menu."  It seems to me that this describes what I want to achieve.

What I don't understand is how to use this property. The property accepts System.Object. I have no idea what object to pass in as I can't see any documentation! For example is it an instance of IDictionary<FilterType, IEnumerable<Operator>>?

Regards

Dario


JP Jeevakanth Palaniappan Syncfusion Team March 19, 2021 12:31 PM UTC

Hi Dario, 

We don’t have support for the Operator parameter in GridFilterSettings but based on your requirement, we suggest you to set the required operators in args.FilterOperators of OnActionBegin event of the grid. Please refer the below code snippet and the sample for your reference. 

@using Syncfusion.Blazor.Grids 
@using Syncfusion.Blazor 
 
<SfGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315"> 
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings> 
    <GridEvents OnActionBegin="ActionBegin" TValue="Order"></GridEvents> 
    <GridColumns> 
.. 
.. 
    </GridColumns> 
</SfGrid> 
 
@code{ 
public async Task ActionBegin(ActionEventArgs<Order> Args) 
{ 
    if (Args.RequestType == Syncfusion.Blazor.Grids.Action.FilterBeforeOpen) 
    { 
        if (Args.ColumnName == "CustomerID") 
            Args.FilterOperators = CustomerIDOperator;     //Assign your required list of operators to FilterOperators
    } 
    ... 
} 
 
public class Operators 
{ 
    public string Value { getset; } 
    public string Text { getset; } 
} 
List<objectCustomerIDOperator = new List<object> { 
new Operators() { Text= "Equal", Value= "equal" }, 
new Operators() { Text= "Contains", Value= "contains" } }; 
 


And we are currently facing difficulties in applying the above suggestion to Date, DateTime and Number typed columns. So we have logged this as an issue “Problem with customizing operators for Date, DateTime, Number column in OnActionBegin event”, the fix for this issue will be available in our upcoming patch release which is expected to be rolled out by the end of March 2021. 

You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.     

Regards, 
Jeevakanth SP. 



JB James Belcher May 24, 2023 02:03 PM UTC

Has this issue with applying custom operators for Date and DateTime columns been resolved? I'm having the same problem with the Javascript ES5 Grid control version 21.2.3



MS Monisha Saravanan Syncfusion Team May 25, 2023 12:40 PM UTC

Hi James,


We have created an separate Forum for your query. So kindly follow the mentioned thread for additional information.


Regards,

Monisha


Loader.
Up arrow icon