DataGrid without LoadData resets columns visibility #1152

Closed
opened 2026-01-29 17:49:38 +00:00 by claunia · 2 comments
Owner

Originally created by @marekm294 on GitHub (Mar 3, 2024).

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.

Originally created by @marekm294 on GitHub (Mar 3, 2024). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **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.
Author
Owner

@enchev commented on GitHub (Mar 4, 2024):

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.

@enchev commented on GitHub (Mar 4, 2024): 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.
Author
Owner

@marekm294 commented on GitHub (Mar 4, 2024):

@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.

@marekm294 commented on GitHub (Mar 4, 2024): @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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1152