<RadzenDataGrid ...
RowExpand="OnExpandRow"
RowRender="@RowRender"
async Task OnExpandRow(SeriesView seriesView)
{
CollectionEntry<SeriesView, SampleView> sampleCollection = DbContext.Entry(seriesView)
.Collection(x => x.Samples);
if (!sampleCollection.IsLoaded)
{
await sampleCollection.LoadAsync()
.ContinueWith(async x =>
{
await Task.Yield();
await InvokeAsync(StateHasChanged);
});
}
}
void RowRender(RowRenderEventArgs<SeriesView> args)
{
args.Expandable = args.Data.SampleCount > 0;
}
In my experience the OnExpandRow method has only 75% chance to re-render loaded collection when the grid has just initialized. The collection is fetched from db, no issues with that, but it's often fails to re-render the expanded section, claiming that there are no records (which is not true)
I also noticed that it only happens after a grid is loaded for the first time. Each consecutive attempt to load the collection is always a success.
I tried regular StateHasChanged, invoke async, Task.Yield, combination of those, but nothing helped to re-render fetched collection every tine.
Radzen.Blazor" Version="5.2.4", server-side rendering