Trying to have only "Contains" option in menu filtering with data grid

Hello. 
I'm trying to have the only option for filtering when using a data grid "Contains". I asked this on the live chat and one solution proposed was using this 

However this still leaves me with all the options in the data grid filter as you can see in the following screenshot. 


Is there something wrong that I am doing or am I not using the Operators property in the right way? 
Looking forward to hearing from you.
Thanks,
Mihai

5 Replies

VN Vignesh Natarajan Syncfusion Team June 19, 2020 05:12 AM UTC

Hi Mihai,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I'm trying to have the only option for filtering when using a data grid "Contains". I asked this on the live chat and one solution proposed was using this  
 
We have understand your query and your solution is used to change the filter options for number column. since you have used it as numberOperator. So If you want to change the string operators, kindly refer the below code example 
 
@using Syncfusion.Blazor.Grids 
  
<SfGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315"> 
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu" Operators="opts"></GridFilterSettings> 
    <GridColumns> 
. . . . . . . . 
    </GridColumns> 
</SfGrid> 
  
@code{ 
    public class Filteroptions 
    { 
        public object @stringOperator { getset; } 
        public Filteroptions(object p) 
        { 
            this.@stringOperator = p; 
        } 
    } 
    public object opts { get; } = new Filteroptions( 
       new List<object> 
        { 
            new { text = "Contains", value = "contains" } 
  
            }); 
     
 
Refer the below screenshot for your reference 
 
 
 
For your convenience we have prepared a sample which can be downloaded from below  
 
 
Also refer our documentation on changing the default operator for particular column from below  
 
 
Kindly get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 



NA Naveen September 19, 2020 12:41 PM UTC

Hi Natarajan,

 The provided solution is not working with  Syncfusion.Blazor18.2.0.58. Can you please look into it?.


Thanks,
Naveen.


VN Vignesh Natarajan Syncfusion Team September 21, 2020 08:33 AM UTC

Hi Naveen, 
 
Query: “The provided solution is not working with  Syncfusion.Blazor18.2.0.58. Can you please look into it?. 
 
We suggest you to achieve your requirement using OnActionBegin event of the Grid while using 18.2.0.58 version (Syncfusion.Blazor) Nuget package. We can change the MenuFilter Operators using FilterOperators property of the OnActionBegin event argument when RequestType is FilterBeforeOpen. Refer the below code example.  
 
<SfGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315"> 
    <GridEvents OnActionBegin="OnActionbegin" TValue="Order"></GridEvents> 
    <GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings> 
. . . . . . . . . 
</SfGrid> 
  
@code{ 
    public List<Order> Orders { getset; } 
    public void OnActionbegin(ActionEventArgs<Order> Args) 
    { 
        if (Args.RequestType == Syncfusion.Blazor.Grids.Action.FilterBeforeOpen) 
        { 
            Args.FilterOperators = new List<object> 
            { 
              new { Text = "Contains", Value = "contains" }, 
              new { Text = "endswith", Value = "endswith" } 
            }; 
        } 
    } 
 
 
Refer the below screenshot for your reference 
 
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.   
 
Regards,
Vignesh Natarajan
 



VB Vincent Bray March 19, 2021 02:53 PM UTC

Dear support,
This does not work with version 18.4.0.48. Could you check ?


VN Vignesh Natarajan Syncfusion Team March 22, 2021 07:28 AM UTC

Hi Vincent,  
 
Thanks for contacting Syncfusion support.  
 
Query: “This does not work with version 18.4.0.48. Could you check ? 
 
We have validated the reported query by preparing a sample as per your suggestion using 18.4.0.48 version and we are not able to reproduce the reported issue at our end. We are able to open filter dialog without any exception and perform filtering. Kindly download the sample from below  
 
 
After referring the sample, if you are still facing the reported issue. Kindly get back to us with following details.  
 
  1. Share the Grid code example.
  2. Are you facing any exception in browser console. If yes, share the screenshot of the issue.
  3. Share the video demonstration of the issue along with replication procedure.
  4. If possible share the issue reproducible sample or try to reproduce the reported issue in provided sample and revert back to us.
 
 
Above requested details will be very helpful for us to validate the reported query at our end and provide better solution as early as possible.   
.      
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon