Filter Bar - blank values and "contains"

Is it possible to type the "contains" operator in the default/basic filter bar?
Is it possible to type something that means "not blank"?
Is it possible to pre-filter a column for not blank?

Filter items by contains operator.

Declaration
public const Operator Contains

6 Replies

RS Renjith Singh Rajendran Syncfusion Team January 15, 2021 11:02 AM UTC

Hi Byron, 

Greetings from Syncfusion support. 

Query 1 : Is it possible to type the "contains" operator in the default/basic filter bar? 
We suggest you to refer to the below documentation for more details regarding changing the default operator for the FilterBar. In the below documentation we have changed the default operator for the CustomerID column. 

Query 2 & 3: Is it possible to type something that means "not blank"?Is it possible to pre-filter a column for not blank? 
We are not clear about these query. We suspect that you would like to filter a column on initial rendering. If so, then we suggest you to refer to the below documentation for more details regarding filtering a Grid on its initial rendering. 

Please refer the above suggestions, and if we have misunderstood your requirement or if you are still facing difficulties then kindly share with us the following details for better assistance.  

  1. Share with us a video demo showing your complete requirement and the problem you are facing.
  2. Share with us a detailed description of your complete requirement.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R 



BY Byron replied to Renjith Singh Rajendran January 15, 2021 04:10 PM UTC

Hi Byron, 

Greetings from Syncfusion support. 

Query 1 : Is it possible to type the "contains" operator in the default/basic filter bar? 
We suggest you to refer to the below documentation for more details regarding changing the default operator for the FilterBar. In the below documentation we have changed the default operator for the CustomerID column. 

Query 2 & 3: Is it possible to type something that means "not blank"?Is it possible to pre-filter a column for not blank? 
We are not clear about these query. We suspect that you would like to filter a column on initial rendering. If so, then we suggest you to refer to the below documentation for more details regarding filtering a Grid on its initial rendering. 

Please refer the above suggestions, and if we have misunderstood your requirement or if you are still facing difficulties then kindly share with us the following details for better assistance.  

  1. Share with us a video demo showing your complete requirement and the problem you are facing.
  2. Share with us a detailed description of your complete requirement.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R 


Query 1 : Is it possible to type the "contains" operator in the default/basic filter bar? 
We suggest you to refer to the below documentation for more details regarding changing the default operator for the FilterBar. In the below documentation we have changed the default operator for the CustomerID column. 

Well, no.  I don't need to change the DEFAULT, unless you are saying that the filter bar can only ever have ONE operator.

Let's say names are formatted as LAST, FIRST; so the grid contains:
     SMITH-JONES, Mary Jane
     GATES, Bill
     BIDEN, Joe
     TRUDEAU, Justin
     etc...

I can type TRUD and get back all the Trudeau's. But I'd like to be able to type "Contains 'J', and get back Jane, Joe and Justin. (That's what "contains" means to me.) The doc suggests that there is a "contains" operator but it doesn't say how or if you can type it.

This is the SQL equivalent: " WHERE x LIKE '%search%' "  (The filter bar normally equates to  " WHERE x LIKE 'search%' ")

Query 2 & 3: Is it possible to type something that means "not blank"?Is it possible to pre-filter a column for not blank? 
We are not clear about these query. We suspect that you would like to filter a column on initial rendering. If so, then we suggest you to refer to the below documentation for more details regarding filtering a Grid on its initial rendering. 

Please highlight for me where that page discusses "NULLs" or "BLANKs". Directing me back to vague documentation without guidance is not the usual level of helpful support that I see from SyncFusion.

Whether I want to do it as an Initial filter or on demand is not relevant.

My grid contains a column that about 30% of the rows do not contain (the field is NULL in sql). I should be able to filter out blanks (or, for that matter, to see ONLY blanks.)

In SQL it would be something like  WHERE X IS NOT NULL AND X <> ''
In C# it would be something like IF ( !string.IsNullOrWhitespace(x) ) ....

Can that not be done from the filter bar?





RN Rahul Narayanasamy Syncfusion Team January 18, 2021 03:03 PM UTC

Hi Byron, 

Query: Is it possible to type the "contains" operator in the default/basic filter bar? -- I can type TRUD and get back all the Trudeau's. But I'd like to be able to type "Contains 'J', and get back Jane, Joe and Justin. (That's what "contains" means to me.) 

We have validated your query and you want to perform filtering operation for a column that contains the particular entered value.  

By default, the filter operator for column is Startswith. You can change the filter. You can change the default filter operator by extending FilterSettings property in the column.  After typing value(J) in filterbar, it will filters the values which contains the given value(J) in the column values. 

<SfGrid DataSource="@Orders" AllowFiltering="true"> 
    <GridFilterSettings> 
        <GridFilterColumns> 
            <GridFilterColumn Field="CustomerID" MatchCase=false Operator="Operator. NotEqual" Predicate="and" Value="@val"></GridFilterColumn> 
        </GridFilterColumns> 
    </GridFilterSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" FilterSettings="@(new FilterSettings{ Operator = Operator.Contains })" 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> 
    </GridColumns>you 
</SfGrid> 


Query: Is it possible to type something that means "not blank"? Is it possible to pre-filter a column for not blank? 

We have validated the query and we might suspect that you want to perform filtering operation for particular column which does not contains null value at initially. You can achieve your requirement by using below way. 

 
<SfGrid DataSource="@Orders" AllowFiltering="true"> 
    <GridFilterSettings> 
        <GridFilterColumns> 
            <GridFilterColumn Field="CustomerID" MatchCase=false Operator="Operator. NotEqual" Predicate="and" Value="@val"></GridFilterColumn> 
        </GridFilterColumns> 
    </GridFilterSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" FilterSettings="@(new FilterSettings{ Operator = Operator.Contains })" Width="150"></GridColumn> 
        . . . 
</SfGrid> 
 
 
@code{ 
    public List<Order> Orders { get; set; } 
    public string val = null; 
 
    . ..  
} 

So it will filter the CustomerID column and shows the values which does not contains null values. 


If you want to perform filtering operation for null values, then you can type null in filterbar and press enter. It will show all the rows which contains null value for particular column. 


Please let us know if you have any concerns. 

Regards, 
Rahul 



BY Byron replied to Rahul Narayanasamy January 20, 2021 10:30 PM UTC

Hi Byron, 

Query: Is it possible to type the "contains" operator in the default/basic filter bar? -- I can type TRUD and get back all the Trudeau's. But I'd like to be able to type "Contains 'J', and get back Jane, Joe and Justin. (That's what "contains" means to me.) 

We have validated your query and you want to perform filtering operation for a column that contains the particular entered value.  

By default, the filter operator for column is Startswith. You can change the filter. You can change the default filter operator by extending FilterSettings property in the column.  After typing value(J) in filterbar, it will filters the values which contains the given value(J) in the column values. 

<SfGrid DataSource="@Orders" AllowFiltering="true"> 
    <GridFilterSettings> 
        <GridFilterColumns> 
            <GridFilterColumn Field="CustomerID" MatchCase=false Operator="Operator. NotEqual" Predicate="and" Value="@val"></GridFilterColumn> 
        </GridFilterColumns> 
    </GridFilterSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" FilterSettings="@(new FilterSettings{ Operator = Operator.Contains })" 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> 
    </GridColumns>you 
</SfGrid> 


Query: Is it possible to type something that means "not blank"? Is it possible to pre-filter a column for not blank? 

We have validated the query and we might suspect that you want to perform filtering operation for particular column which does not contains null value at initially. You can achieve your requirement by using below way. 

 
<SfGrid DataSource="@Orders" AllowFiltering="true"> 
    <GridFilterSettings> 
        <GridFilterColumns> 
            <GridFilterColumn Field="CustomerID" MatchCase=false Operator="Operator. NotEqual" Predicate="and" Value="@val"></GridFilterColumn> 
        </GridFilterColumns> 
    </GridFilterSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" FilterSettings="@(new FilterSettings{ Operator = Operator.Contains })" Width="150"></GridColumn> 
        . . . 
</SfGrid> 
 
 
@code{ 
    public List<Order> Orders { get; set; } 
    public string val = null; 
 
    . ..  
} 

So it will filter the CustomerID column and shows the values which does not contains null values. 


If you want to perform filtering operation for null values, then you can type null in filterbar and press enter. It will show all the rows which contains null value for particular column. 


Please let us know if you have any concerns. 

Regards, 
Rahul 


Thank you. We are getting closer.

For Query 1:
Is it not possible to TYPE the query operator in the filter bar? In other words, the filter bar is locked to one kind of operation? In almost all other free-form search/filters, you can type an operator in the field ...  for example, putting a word in quotes in a google search makes it mandatory. 

If you look at this SyncFusion page https://blazor.syncfusion.com/documentation/datagrid/filtering/ , under the sub-head "Fiter bar", the documentation status that "you can enter the following filter expressions (operators) manually in the filter bar". This doesn't just _imply_ it directly states that you can override the "default" action.

However.... (a) "Contains" is not listed in this table, and (b) = and * are BOTH listed as "Startwith" (one for strings and one for dates). Was it deliberate to not let a user type an operator for "contains"?  I appreciate that you have told me twice that I can change the default, but that is NOT what I asked. I asked "Is it possible to type the "contains" operator in the default/basic filter bar?"    I gather that your answer is "no, you cannot type it but you can change the default." Is this correct?


For Query 2:

Filtering the initial display was, I guess, a "Query 3". Query two is "Is it possible to TYPE [in the filter bar], something that means "not blank?"


Use case:

The user is looking at a grid.

The grid has 80,000 contacts.

Half of the contacts have a blank or null for "email address"

The user, at run time, all on his or her own, says to himself "I'd like to look at just the ones with email addresses".

What, if anything, can they type in the filter bar to eliminate all the blanks.?


Thank you.

PS: On this Rich Text Editor, cutting and pasting screws up the formatting. :(



VN Vignesh Natarajan Syncfusion Team January 27, 2021 04:02 AM UTC

Hi Byron,  

Thanks for the explanation.  

We have analyzed your query and currently we are validating the feasibilities of achieving your requirement. We will update you the further details in two business days.  

Till then we appreciate your patience.  

Regards, 
Vignesh Natarajan  



RN Rahul Narayanasamy Syncfusion Team January 28, 2021 02:23 PM UTC

Hi Byron, 

Thanks for your patience. 

Query 1: Is it not possible to TYPE the query operator in the filter bar? In other words, the filter bar is locked to one kind of operation? In almost all other free-form search/filters, you can type an operator in the field ...  for example, putting a word in quotes in a google search makes it mandatory. 

We have validated your query and you can achieve your requirement by using FilterTemplate. In this filter template you can type the operator and value in rendered textbox(in FilterTemplate) and you can perform the operation using FilterByColumn method. 

 
<SfGrid @ref="Grid" DataSource="@Orders" AllowFiltering="true"> 
    <GridEvents OnActionBegin="Begin" TValue="Order"></GridEvents> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"> 
            <FilterTemplate> 
                <SfTextBox @ref="TextBox" Placeholder="Customer Name" ID="CustomerID" @onkeydown="@Enter" Value="@((string)(context as PredicateModel).Value)" ></SfTextBox> 
            </FilterTemplate> 
        </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> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    SfTextBox TextBox; 
    SfGrid<Order> Grid; 
    public List<Order> Orders { get; set; } 
    public string val = null; 
 
    . . . 
 
    public async Task Enter(KeyboardEventArgs e) 
    { 
        if (e.Code == "Enter" || e.Code == "NumpadEnter") 
        { 
            //you can get the entered value in text box reference(TextBox.Value) and perform filter operation using FilterByColumn method with typed operator and value 
            await Grid.FilterByColumn("CustomerID", operator, value); 
        } 
    } 
} 


Query: Filtering the initial display was, I guess, a "Query 3". Query two is "Is it possible to TYPE [in the filter bar], something that means "not blank?" 

We have validated your query and you want to filter the values which are not null/ blank. You can achieve your requirement by using FilterTemplate. Find the below code snippets and sample for your reference. 

 
<SfGrid @ref="Grid" DataSource="@Orders" AllowFiltering="true"> 
    <GridEvents OnActionBegin="Begin" TValue="Order"></GridEvents> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"> 
            <FilterTemplate> 
                <SfTextBox @ref="TextBox" Placeholder="Customer Name" ID="CustomerID" @onkeydown="@Enter" Value="@((string)(context as PredicateModel).Value)" ></SfTextBox> 
            </FilterTemplate> 
        </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> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    SfTextBox TextBox; 
    SfGrid<Order> Grid; 
    public List<Order> Orders { get; set; } 
    . . . 
 
    public async Task Enter(KeyboardEventArgs e) 
    { 
        if (e.Code == "Enter" || e.Code == "NumpadEnter") 
        { 
            await Grid.FilterByColumn("CustomerID", "notequal", TextBox.Value.Replace('"', ' ').Trim()); 
        } 
    } 
} 


Please let us know if you have any concerns. 

Regards, 
Rahul 


Loader.
Up arrow icon