RadzenDataGrid reapply filter,sort values

Is there a way to store the filter values , sort values by user last session save them and apply it to the grid at OnInitialization or any function .I have found the filter value in this property it is like query ,but dont know how to apply it to grid and reload it .Other than LoadData method as my Load method looks like this

protected async Task Load()
matrixDBmodel = await dbMatrix.GetAllMatrixData();
getMatrix = matrixDBmodel;


This is very interesting for me too!

Sort and Filter properties are strings that can be applied again using LoadData since the event is called on initial load of the DataGrid. Check our demo for reference:

If you wish you can apply the same to filter and sort the collection before assigning to the DataGrid - you can use Dynamic LINQ similar to our demo.

Thanks @enchev ,Is it possible with normal collection like IEnumerable getMatrix without using dynamic Linq. If I update a row and save changes grid0.Reload() is able to retain the filter values but not reflecting the grid values so I have to use await Load() ; inorder to reflect those updated values in the grid but then the filter values are lost :confused: . Not sure what I am doing wrong exactly . Any help appreciated
<RadzenDataGrid @ref="analyticMatrixGrid" AllowFiltering="true" AllowPaging="true" PageSize="15" AllowSorting="true" RowRender="@RowRender" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" ExpandMode="DataGridExpandMode.Single" Data="@getAnalyticMatrix" TItem="AnalyticsMatrixDBObject" RowExpand="RowExpand" RowSelect="@OnRowSelect">

protected RadzenDataGrid<AnalyticsMatrixDBObject> analyticMatrixGrid;
IEnumerable<AnalyticsMatrixDBObject> analyticMatrixDBmodel;
IEnumerable<AnalyticsMatrixDBObject> _getAnalyticMatrix;

int count;
protected IEnumerable<AnalyticsMatrixDBObject> getAnalyticMatrix
        return _getAnalyticMatrix;
        if (!object.Equals(_getAnalyticMatrix, value))
            var args = new PropertyChangedEventArgs() { Name = "getAnalyticMatrix", NewValue = value, OldValue = _getAnalyticMatrix };
            _getAnalyticMatrix = value;
            //_getAnalyticMatrix = value;
            //InvokeAsync(() => { StateHasChanged(); });

protected override async Task OnInitializedAsync()
    await Load();

protected async Task Load()
    analyticMatrixDBmodel = await dbAnalyticMatrix.GetAllAnalyticsMatrixData();
    getAnalyticMatrix = analyticMatrixDBmodel;


protected async Task OnRowSelect(AnalyticsMatrixDBObject args)
    String filter = analyticMatrixGrid.Query.Filter;
    var result = await DialogService.OpenAsync<EditAnalyticRule>("Edit Analytic Rule", new Dictionary<string, object>() { { "AnalyticRuleID", args.ID } }, new DialogOptions() { Width = "1200px" });
    await analyticMatrixGrid.Reload();
    await InvokeAsync(() => { StateHasChanged(); });
    await Load();
    var query = getAnalyticMatrix.AsQueryable();
    if (!string.IsNullOrEmpty(filter))
        query = query.Where(filter);
    getAnalyticMatrix = query.ToList();


I'm afraid that it will be very hard. DataGrid provides sorts and filters as strings and Dynamic LINQ are actually bunch of extension methods that can be applied to any IEnumerable<>.

Hey all,
I want to save the Filter (by User) into the Database.
Which LoadDataArgs parameter do I need to reapply the filter?

And after reload the page, I want to rewrite the filter condition back to the grid?
How do I?

args.Filter = 'OrderNo eq -9622 and Year eq 2021 and contains(tolower(Status), tolower('can'))'

Im very interested at that too!

1 Like

See my solution here (using clientstorage to presist the applied filter values (or whatever you need)):
Preserving state of the data grid through navigations - Radzen.Blazor Components - Radzen
Hope it helps!