EnablePersistence and Filter on text columns

Hi,

I'm facing an issue when using the EnablePersistence property.

When using the filter on a numeric field, it works as expected.
Unfortunately, when setting a filter in a text-field, when (re)loading the page, it shows the filter value correctly in the filter column, but shows no values in the grid.
When removing the filter and applying the same filter again, it does work the same as before.

Code to reproduce the issue:
-----

@using Syncfusion.Blazor
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Data

<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">
            <SfGrid TValue="OrdersDetails"
                    ID="id-for-table" AllowReordering="true" EnablePersistence="true"
                    AllowSorting="true" AllowMultiSorting="true" AllowFiltering="true" AllowResizing="true" ShowColumnChooser="false" ShowColumnMenu="true"
                    AllowPaging="true" AllowPdfExport="true">
                <GridPageSettings PageSize="12" PageSizes="new int[]{ 5, 10, 12, 15, 20 }" />
                <SfDataManager Url="https://js.syncfusion.com/demos/ejservices/Wcf/Northwind.svc/Orders" CrossDomain="true" Adaptor="Adaptors.ODataAdaptor"></SfDataManager>
                <GridColumns>
                    <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText="Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>
                </GridColumns>
                <GridFilterSettings Mode="@FilterBarMode.OnEnter" ShowFilterBarStatus="false" Type="@Syncfusion.Blazor.Grids.FilterType.FilterBar">
                    <GridFilterColumns>
                        <GridFilterColumn Field="@nameof(OrdersDetails.OrderID)" Operator="@Operator.NotEqual" Value="0" Predicate="and" />
                    </GridFilterColumns>
                </GridFilterSettings>
            </SfGrid>
        </div>
    </div>
</div>

@code {
    class OrdersDetails {
        public int OrderID { get; set; }
        public string CustomerID { get; set; }
        public DateTime OrderDate { get; set; }
        public Decimal Freight { get; set; }
        public string ShipCountry { get; set; }
    }
}

-----

I have been able to find that this has to do with (missing) quotes in the persisted data.
When I change the persisted data in localStorage from
{ ... ,"filterSettings":{"Columns":[{ ... },{"Field":"ShipCountry","IgnoreAccent":false,"MatchCase":false,"Operator":2,"Predicate":"and","Uid":"grid-column82","Value":"bel","ActualValue":"bel"}], ...} ... }
to
{ ... ,"filterSettings":{"Columns":[{ ... },{"Field":"ShipCountry","IgnoreAccent":false,"MatchCase":false,"Operator":2,"Predicate":"and","Uid":"grid-column82","Value":"'bel'","ActualValue":"bel"}], ...} ... }
the filtering keeps on working, but it shows the filter value as 'bel' instead of bel.
The change I made was to add single quotes around the string value.


As a side-question, I was wondering if it is possible to enable persistence of a grid, but ignore the filterSettings.

Thanks!


Best regards,
Mike

3 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team November 20, 2020 01:54 PM UTC

Hi Michael, 

Greetings from Syncfusion. 

Query: EnablePersistence and Filter on text columns  

We have validated your query and considered the reported issue as a bug and logged the defect report “String Column Filtering is not working properly in ODataAdaptor/ODataV4Adaptor with EnablePersistance for the same. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle ) and including the defect fix in our upcoming patch release which is expected to be rolled out on or before end of December, 2020.  
     
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.     


Query: if it is possible to enable persistence of a grid, but ignore the filterSettings. 

We have considered this requirement as a usability feature requirement and logged an improvement task “Provide support to customize the list of persisted properties while apply EnablePersistence in Grid” for this requirement. We have planned to implement this and include this feature improvement in any of our upcoming  release. 
 
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.   
 
 
Until then we appreciate your patience.  
 
Regards, 
Rahul 


Marked as answer

GB geoff brooks March 18, 2022 08:05 PM UTC

I can confirm this is working in 19.4.0.56 (or earlier, not sure) - however you must have the ID attribute specified for the SFGrid - Without an ID the EnablePersistence is ignored. I am guessing this has to do with using the ID as a key for saving or fetching it in local storage, but that is just a guess.



RN Rahul Narayanasamy Syncfusion Team March 21, 2022 02:05 PM UTC

Hi Geoff, 

Greetings from Syncfusion. 

Yes, you need to provide ID property to the Grid for persisting the state while using EnablePersistence feature. The state will be persisted based on ID property. So, it is recommended to explicitly set the ID property for Grid. 
 
Find the below documentation for your reference. 

Reference

 


Please let us know if you have any concerns. 

Regards, 
Rahul 


Loader.
Up arrow icon