Filtering one or none


I'm using a single sfGrid  Component twice. In one case, I want the entire list to show. In the second case, I want to pass (as a parameter on  the component) a simple string to filter by. The second case works. I get the grid with the items that match the filter condition. Unfortunately the first case now shows a blank grid. I assume this is because I don't want to pass it a filter. 

I could programmatically turn AllowFiltering to false in that case, but then the filter bar won't show in that rendering.

Is there an Operator to show all?

Here is the markup for that portion of the component:

    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Normal"></GridEditSettings>
    <GridEvents RowSelected="RowSelected" OnActionComplete="ActionCompleteHandler" TValue="Execution"></GridEvents>
    <GridFilterSettings>
        <GridFilterColumns>
            <GridFilterColumn Field = "Symbol" MatchCase="false" Operator = "Operator.StartsWith" Predicate = "and"  Value = "@StockToShow" ></GridFilterColumn>
        </GridFilterColumns>
    </GridFilterSettings>

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team February 11, 2021 01:56 PM UTC

Hi Stephen, 

Greetings from Syncfusion. 

We have validated your query and we suspect that you want to clear the filtering(to show all the records in the Grid) in the already filtered Grid. If yes, then we suggest you to achieve your requirement by using ClearFiltering method of the Grid. Please find the below code snippets and sample for your reference. 

 
<button @onclick="Clear">Clear Filtering</button>     
 
<SfGrid @ref="Grid" ID="Grid" DataSource="@Orders" AllowPaging="true" AllowFiltering="true"> 
    <GridFilterSettings> 
        <GridFilterColumns> 
            <GridFilterColumn Field="CustomerID" MatchCase=false Operator="Operator.StartsWith" Predicate="and" Value="@val"></GridFilterColumn>   //already applied initial filtering 
        </GridFilterColumns> 
    </GridFilterSettings> 
    <GridColumns> 
        . . . 
</SfGrid> 
 
@code{ 
    SfGrid<Order> Grid; 
    public List<Order> Orders { get; set; } 
    public string val = "ANANTR"; 
 
    . . . 
 
    public async Task Clear() 
    { 
        await Grid.ClearFiltering();    //clear filtering 
    } 
} 


Reference

If it does not meet your requirement, then could you please share more details regarding the problem. It will be helpful to validate and provide a better solution. 

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon