[dev-v5][DataGrid] Improve Virtualize handling and data loading#4972
Open
miguelhasse wants to merge 6 commits into
Open
[dev-v5][DataGrid] Improve Virtualize handling and data loading#4972miguelhasse wants to merge 6 commits into
miguelhasse wants to merge 6 commits into
Conversation
- Only render empty content if total count is zero and Virtualize is initialized - In RefreshDataCoreAsync, check Virtualize flag and avoid redundant data loading if component is not ready - Make Task.Delay in ProvideVirtualizedItemsAsync cancellable - In ResolveItemsRequestA, skip ToArrayAsync if count is zero and add cancellation checks before and after data retrieval for better efficiency and responsiveness
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines FluentDataGrid’s virtualization data-loading flow so the grid waits for the Virtualize child component to be available before issuing its first load, and improves cancellation handling during virtualized and async-query execution.
Changes:
- Defer initial virtualized refresh until the
Virtualizecomponent reference is available to avoid duplicate/early loads. - Improve cancellation behavior in the virtualized debounce delay and async query execution (count + page fetch).
- Adjust empty-state rendering for virtualized grids to avoid showing empty content before
Virtualizeis ready.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Core/Components/DataGrid/FluentDataGrid.razor.cs | Updates refresh/virtualized provider logic and async query execution cancellation handling. |
| src/Core/Components/DataGrid/FluentDataGrid.razor | Tweaks empty-state rendering condition for virtualized mode to avoid premature empty UI. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Updated the condition for fetching items to ensure request.Count is not null and greater than zero. This prevents potential null reference issues and makes the code more robust when handling nullable request counts.
dvoituron
approved these changes
Jun 26, 2026
Allow resultArray fetching when request.Count is null or > 0, instead of only when it is > 0. This ensures items are fetched even if request.Count is not specified.
Changed the test assertion to require at least one row instead of exactly two, making the test less strict and more robust to variations in rendered row count.
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.
📖 Description
Refined the virtualized data loading logic in FluentDataGrid.razor and its code-behind to ensure that data is only loaded when the Virtualize component is ready, and to prevent unnecessary or duplicate data loads during the initial render.
Improved async data loading by properly handling cancellation tokens, including catching cancellation exceptions and returning default values when operations are cancelled. This prevents unnecessary errors and ensures the UI remains responsive.
👩💻 Reviewer Notes
The following examples can be used to test behavior enhancements:
AdventureWorks to test using EntityFrameworkAdapter with SQL Server
TripPin to test using ODataAdapter
✅ Checklist
General
Component-specific