Sort order not loading


I've followed advice here,

and here,

But even with a reload, on saved settings, the sorting is not happening when applying saved settings.

I am using a non-virtualized data set. Is there a specific time i need to call Reload other than in the Load Async method above, which is where I'm calling it now after the saved settings are applied? Maybe that's my issue, but can't find another spot to call reload or to get the grid sorted.


It will be easy to solve this problem if you share your code and what you have tried so far :slight_smile:

I tried reload as the article suggested - i really haven't tried anything else because this appeared to be the solution. LoadStateAsync is called from after render async on the first reload also following the guidance in the article. thank you!

 private async Task LoadStateAsync()
        await Task.CompletedTask;

        var result = await JSRuntime.InvokeAsync<string>("window.localStorage.getItem", GridName);
        if (!string.IsNullOrEmpty(result))
            // we should also plan for some bad data here -- right now it's happy path
            Settings = JsonSerializer.Deserialize<DataGridSettings>(result);
            await Reload();


I should add that, if we take the base example and add the line in bold ... sorting appears to work. That is some good news. However, when I add a filter, "SettingsChanged" gets called twice -- once with the filter value, once with null, so the filter is not really applied.

Thoughts or suggestions on this trial or alternate ideas?

  protected override async Task OnAfterRenderAsync(bool firstRender)
        **await base.OnAfterRenderAsync(firstRender);**

        if (firstRender)
            await LoadStateAsync();

Hi Thepear,
I think you have the same problem as me (I saw your las post in february)
see my post: RadzenDataGrid and Default SortOrder and DataGridSettings Bug
I correct it in Radzen source, I think, it will be in a new version sometimes...

@awolf -- there are some similarities ... but i did just find the following tidbit ...

I was using an OnFilter event -- this way i can call my api with the actual filter and not just have it filtered in the grid. when I remove this handler, the settings overrides losing filters "goes away".

I need to use that event .. so i will continue exploring options.

FWIW - line 593

The call to OnFilter is not awaited. I'm not sure if this is the issue ... but when i have a Filter handler, the filters do not work with capturing SettingsChanged event.