radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.6k stars 802 forks source link

DataGrid without LoadData resets columns visibility #1406

Closed marekm294 closed 8 months ago

marekm294 commented 8 months ago

Describe the bug https://blazor.radzen.com/datagrid-save-settings - this example works nice but once you add Task.Delay() (simulation of data load) columns visibility (and maybe more) settings will stop to work.

To Reproduce Add Delay to simulate data loading in example page (link is above)

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();
        await Task.Delay(1000);        
        employees = dbContext.Employees;
    }

When you do this change, Columns visibility will be reseted after loading data.

This is happening because OnDataChanged() is called after Settings is loaded from LocalStorage. In OnDataChanged() method the Reset() method is called. Reset() method will reset columns visibility. I believe this is not desired behavior in this case.

enchev commented 8 months ago

Delayed binding can definitely cause such problems since will brake the lifecycle of component loading from settings. You can check loading settings when binging with LoadData.

marekm294 commented 8 months ago

@enchev It's not about delayed binding this bug. Imagine you want to load data on button click. The problem si you reset column visibility OnDataChange() when there's Settings.