I am using SyncFusion.Blazor v18.2.0.47
I have a grid where I have a FilterTemplate on a column to allow the user to select from a dropdownlist. This all works as expected. However, now I need to persist the selected filter when I navigate away from the page with the list so that the filter is applied once I navigate back to the list.
I have EnablePersistence="true" on the grid. When I apply the filter, navigate away and then navigate back, it does not apply the filter.
I tried applying a sort as well, using the built-in grid sorting, and when I sort, navigate away and then navigate back, the sort persists as expected. Just the filter is not persisting.
Here is my Grid markup;
<SfGrid @ref="@Grid" ID="productList" TValue="Product" AllowPaging="true" AllowFiltering="true" AllowSorting="true" EnablePersistence="true">
<GridEvents OnActionComplete="ActionCompleteHanlder" TValue="Product"></GridEvents>
<GridPageSettings PageSize="@DefaultPageSize" PageSizes="@PageSizes"></GridPageSettings>
<SfDataManager Headers="@HeaderData" Url="@CdApiUrl" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>
<GridSortSettings>
<GridSortColumns>
<GridSortColumn Field="Name" Direction="SortDirection.Ascending"></GridSortColumn>
</GridSortColumns>
</GridSortSettings>
<GridColumns>
<GridColumn HeaderText="" Width="150px" AllowFiltering="false">
<Template>
@{
var product = (context as Product);
<button Class="btn btn-outline-primary"
@onclick="@(_ =>
{
if (product != null) HandleProductSelectClick(product.Id);
})">
<span class="far fa-edit"></span> Manage
</button>
}
</Template>
</GridColumn>
<GridColumn Field=@nameof(Product.PartNumber) HeaderText="Part Number" FilterSettings="@Filtering" Width="150"></GridColumn>
<GridColumn Field=@nameof(Product.Name) HeaderText="Product Name" FilterSettings="@Filtering"></GridColumn>
<GridColumn Field=@nameof(Product.ProductChannel) HeaderText="Channel" Width="150">
<FilterTemplate>
<SfDropDownList PlaceHolder="Channel Type" ID="Channel" Value="@((string)(context as PredicateModel).Value)" DataSource="@ChannelTypeValues" TValue="string" TItem="string">
<DropDownListEvents ValueChange="@HandleChangeChannelTypeFilter" TValue="string"></DropDownListEvents>
<DropDownListFieldSettings Value="string" Text="string"></DropDownListFieldSettings>
</SfDropDownList>
</FilterTemplate>
</GridColumn>
<GridColumn Field=@nameof(Product.Status) HeaderText="Status" Width="150px">
<FilterTemplate>
<SfDropDownList PlaceHolder="Status Type" ID="Status" Value="@((string)(context as PredicateModel).Value)" DataSource="@StatusTypeValues" TValue="string" TItem="string">
<DropDownListEvents ValueChange="@HandleChangeStatusTypeFilter" TValue="string"></DropDownListEvents>
<DropDownListFieldSettings Value="string" Text="string"></DropDownListFieldSettings>
</SfDropDownList>
</FilterTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
And here are my handlers for applying the filters;
protected void HandleChangeStatusTypeFilter(ChangeEventArgs<string> args)
{
if (args.Value == "All")
{
Grid.ClearFiltering();
ShowClearFilterButton = false;
}
else
{
Grid.FilterByColumn("Status", "equal", args.Value, null, true);
ShowClearFilterButton = true;
}
}
protected void HandleChangeChannelTypeFilter(ChangeEventArgs<string> args)
{
if (args.Value == "All")
{
Grid.ClearFiltering();
ShowClearFilterButton = false;
}
else
{
Grid.FilterByColumn("ProductChannel", "equal", args.Value, null, true);
ShowClearFilterButton = true;
}
}
What am I missing here?