Hi,
I'm running into an issue when combining the Radzen DataGrid
's settings persistence (Save/Load settings) with grouping via the OnRender
event.
Example
void OnRender(DataGridRenderEventArgs<Order> args)
{
if (args.FirstRender)
{
args.Grid.Groups.Add(new GroupDescriptor()
{
Property = "Employee.LastName",
Title = "Employee"
});
StateHasChanged();
}
}
The Problem:
When using this method to group by "Employee.LastName"
during the first render, it causes the grid settings stored in localStorage
to be overwritten/reset — effectively discarding any previously saved user settings.
I initially thought I could fix this by checking if the grouping already exists in the current settings:
“If
"Employee.LastName"
already exists in settings, do nothing — else, add it.”
However, there's a timing issue:
- The
OnRender
method is triggered beforeLoadStateAsync
has finished loading the saved settings. - So the grouping check is always
false
, and the grouping is added again → overwriting the saved state.
Has anyone found a reliable way to:
- Add grouping dynamically via
OnRender
, only if it's not already saved, - without overwriting existing
DataGrid
settings?