We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Cannot filter with Operator=@Operator.Contains

Thread ID:





151149 Feb 1,2020 11:14 AM UTC Feb 2,2020 04:51 AM UTC Blazor 1
Tags: Grid
Peter Morris
Asked On February 1, 2020 11:14 AM UTC

Filtering works nicely for StartsWith, but when I set the operator to Contains it still acts as if it were set to StartsWith

How can I fix this?

@page "/"

<h1>Hello, world!</h1>

<EjsGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true">
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
        <GridFilterColumn Field=@nameof(Order.CustomerID) Operator=@Syncfusion.EJ2.Blazor.Operator.Contains/>

    public List<Order> Orders { get; set; }

    protected override void OnInitialized()
        Orders = Enumerable.Range(1, 75).Select(x => new Order()
            OrderID = 1000 + x,
            CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
            Freight = 2.1 * x,
            OrderDate = (new DateTime[] { new DateTime(2010, 5, 1), new DateTime(2010, 5, 2), new DateTime(2010, 5, 3), })[new Random().Next(3)],

    public class Order
        public int? OrderID { get; set; }
        public string CustomerID { get; set; }
        public DateTime? OrderDate { get; set; }
        public double? Freight { get; set; }

Madhu Sudhanan P [Syncfusion]
Replied On February 2, 2020 04:51 AM UTC

Hi Peter, 
Greetings from Syncfusion support.  
To change the default filter operator for particular column (CustomerID) in Grid. We suggest you to define the filter operator at column level using Filter property. Refer the below code example.  
<EjsGrid DataSource="@Orders" AllowFiltering="true" AllowPaging="true" Height="315"> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Center" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name"  Filter="@FilterParams" TextAlign="TextAlign.Center" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Center" Width="130"></GridColumn> 
        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Center" Width="120"></GridColumn> 
    object FilterParams = new { @@operator = "contains" }; 
    . . .  . .   
Note: GridFilterSettings is used to set default filtered columns or initial filtering to the Grid. If you want to change the default operator kindly refer the above solution. 
Kindly refer our UG documentation for your reference. 
Please get back to us if you have further queries.      
Madhu Sudhanan P 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon