DataGridSettings not set on RadzenDataGrid.Reset() anymore #1653

Closed
opened 2026-01-29 17:56:48 +00:00 by claunia · 5 comments
Owner

Originally created by @ArturAdam on GitHub (Mar 5, 2025).

DataGridSettings not set on RadzenDataGrid.Reset(). The call to SaveSettings was removed from the Reset method breaks the behaviour when loading the data from session storage when Settings is bound via @bind-Settings. (Settings will always be null)

Pseudo Example:

<RadzenDataGrid @ref="dataGrid" TValue="Item" @bind-Settings="@settings">
    <Columns>
        <RadzenDataGridColumn TItem="Item" Property="Id" Title="ID" />
        <RadzenDataGridColumn TItem="Item" Property="Name" Title="Name" />
    </Columns>
</RadzenDataGrid>


@code {
   private RadzenDataGrid<Item> dataGrid;
  
   private DataGridSettings? _settings;
   public DataGridSettings? Settings
      {
          get => _settings;
          set
          {
              if (_settings != value)
              {
                  _settings = value;
                  InvokeAsync(() => SaveStateAsync());
              }
          }
      }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (!firstRender)
            return;

        Settings = await LoadStateAsync();

        // Reset to force Settings to instantiate
        if(Settings is null)
            dataGrid.Reset();

        // apply some filter here 
        StateHasChanged();
    }

}
Originally created by @ArturAdam on GitHub (Mar 5, 2025). DataGridSettings not set on RadzenDataGrid.Reset(). The call to SaveSettings was removed from the Reset method breaks the behaviour when loading the data from session storage when Settings is bound via @bind-Settings. (Settings will always be null) Pseudo Example: ``` <RadzenDataGrid @ref="dataGrid" TValue="Item" @bind-Settings="@settings"> <Columns> <RadzenDataGridColumn TItem="Item" Property="Id" Title="ID" /> <RadzenDataGridColumn TItem="Item" Property="Name" Title="Name" /> </Columns> </RadzenDataGrid> @code { private RadzenDataGrid<Item> dataGrid; private DataGridSettings? _settings; public DataGridSettings? Settings { get => _settings; set { if (_settings != value) { _settings = value; InvokeAsync(() => SaveStateAsync()); } } } protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) return; Settings = await LoadStateAsync(); // Reset to force Settings to instantiate if(Settings is null) dataGrid.Reset(); // apply some filter here StateHasChanged(); } } ```
Author
Owner

@enchev commented on GitHub (Mar 5, 2025):

There are no recent changes in Reset() method related to this:
https://github.com/radzenhq/radzen-blazor/blame/master/Radzen.Blazor/RadzenDataGrid.razor.cs#L2050-L2077
Image

@enchev commented on GitHub (Mar 5, 2025): There are no recent changes in Reset() method related to this: https://github.com/radzenhq/radzen-blazor/blame/master/Radzen.Blazor/RadzenDataGrid.razor.cs#L2050-L2077 ![Image](https://github.com/user-attachments/assets/9c229ca3-00fd-4ba5-b7a1-9d9a6dbc2458)
Author
Owner

@ArturAdam commented on GitHub (Mar 5, 2025):

here

@ArturAdam commented on GitHub (Mar 5, 2025): [here](https://github.com/radzenhq/radzen-blazor/commit/28fc95dd1fd0b58545cb52f4ccf4daa4070a2387)
Author
Owner

@enchev commented on GitHub (Mar 5, 2025):

I see. This change is a fix for: https://forum.radzen.com/t/datagrid-settings-lifecycle-related-issues/16944/8
I'm afraid that we are not aware of other fixes.

@enchev commented on GitHub (Mar 5, 2025): I see. This change is a fix for: https://forum.radzen.com/t/datagrid-settings-lifecycle-related-issues/16944/8 I'm afraid that we are not aware of other fixes.
Author
Owner

@ArturAdam commented on GitHub (Mar 5, 2025):

Could you expose the SaveSettings method? As a workaround I just copied that method into my project

@ArturAdam commented on GitHub (Mar 5, 2025): Could you expose the SaveSettings method? As a workaround I just copied that method into my project
Author
Owner

@ArturAdam commented on GitHub (Mar 6, 2025):

thank you!

@ArturAdam commented on GitHub (Mar 6, 2025): thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1653