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