Repository navigation
[DataGrid] Re-render the grid after RefreshDataAsync with Virtualize - #5488
Merged
Denis Voituron (dvoituron) merged 2 commits intoOct 21, 2026
Merged
Denis Voituron (dvoituron) merged 2 commits into
Denis Voituron (dvoituron) merged 2 commits into
Conversation
Since microsoft#4972 the Virtualize branch of RefreshDataCoreAsync returns early after delegating to Virtualize.RefreshDataAsync, skipping the final StateHasChanged. When the total item count did not change, the grid itself was never re-rendered. RefreshDataAsync now renders the grid after refreshing, as QuickGrid does. InvokeAsync keeps it callable from outside the renderer's synchronization context.
Pierluigi Amato (giga487)
requested review from
Denis Voituron (dvoituron) and
Vincent Baaij (vnbaaij)
as code owners
October 19, 2026 19:53
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix restores rendering without changing query behavior and includes targeted regression coverage.
No open issues 🎉
What changed in this PR
Fixes the virtualized DataGrid refresh regression introduced by #4972 when the total item count stays unchanged.
Changes:
- Requests a grid render after refreshing data using renderer-safe dispatch.
- Adds regression coverage for refreshes with a stable item count.
| File | Description |
|---|---|
| tests/Core/Components/DataGrid/FluentDataGridTests.razor | Tests that virtualized refreshes re-render the grid. |
| src/Core/Components/DataGrid/FluentDataGrid.razor.cs | Adds InvokeAsync(StateHasChanged) after refreshing data. |
Review effort: Balanced
Contributor
Author
|
@microsoft-github-policy-service agree |
Denis Voituron (dvoituron)
approved these changes
Oct 21, 2026
This was referenced Nov 16, 2026
Merged
Closed
This was referenced Nov 30, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
📖 Description
When
Virtualize="true", callingRefreshDataAsync()refreshes the data but does not re-render the grid itself when the total item count does not change.Since #4972, the Virtualize branch of
RefreshDataCoreAsyncreturns early after delegating toVirtualize.RefreshDataAsync()(to avoid a second query). That early return also skips the finalStateHasChanged(), which was the only place the grid re-rendered.ProvideVirtualizedItemsAsynconly renders the grid on the first result or when the total count changes, so a plain refresh left the grid stale.The comment on
RefreshDataCoreAsyncalready says it is "Same as RefreshDataAsync, except without forcing a re-render". So the public method now forces the render, as ASP.NET CoreQuickGriddoes. It usesawait InvokeAsync(StateHasChanged)rather than a directStateHasChanged(), soRefreshDataAsync(and the public APIs built on it:SetSortAsync,SortByColumnAsync, ...) can still be called from outside the renderer's synchronization context. A direct call breaks 60 existing tests that do this.In the non-virtualized path an
InvokeAsync(StateHasChanged)is already queued; the extra render request is batched by Blazor.🎫 Issues
👩💻 Reviewer Notes
The fix is a single line in
FluentDataGrid.RefreshDataAsync. Please take a look at the choice ofInvokeAsync(StateHasChanged)overStateHasChanged()(see above).📑 Test Plan
FluentDataGrid_Virtualize_RefreshDataAsync_RerendersGrid: a virtualized grid with a stable item count must re-render afterRefreshDataAsync(). It fails without the fix and passes with it.CalendarExtendedTests.GetDaysOfWeek_ReturnsCorrectDays(date parsing in the DateTimes utilities, not touched by this PR).✅ Checklist
General
AI contribution declaration
AI assistance is allowed; fully AI-generated or autonomous pull requests without meaningful human review are not accepted. See the AI contribution policy.
Component-specific
⏭ Next Steps
None.