Skip to content

Conversation

dariatiurina
Copy link
Contributor

Fix two loads in QuickGrid with Virtualize

Description

This pull request introduces an optimization to the data loading logic for the QuickGrid component, specifically when using virtualization. The main goal is to prevent redundant data loading on the initial render, improving performance and user experience.

Virtualization data loading optimization:

  • Added a _firstRefreshDataAsync flag to the QuickGrid class to track whether the initial data load has occurred.
  • Updated the RefreshDataCoreAsync method to skip the data loading logic on the first render if virtualization is enabled, allowing the Virtualize component to handle the initial data load itself.

Fixes #55979

@github-actions github-actions bot added the area-blazor Includes: Blazor, Razor Components label Sep 10, 2025
@dariatiurina dariatiurina marked this pull request as ready for review September 10, 2025 13:45
@Copilot Copilot AI review requested due to automatic review settings September 10, 2025 13:45
@dariatiurina dariatiurina requested a review from a team as a code owner September 10, 2025 13:45
@dariatiurina dariatiurina self-assigned this Sep 10, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the QuickGrid component's data loading behavior when virtualization is enabled, preventing redundant data loads on initial render. The optimization introduces a flag to track the first refresh and allows the Virtualize component to handle the initial data loading itself.

Key changes:

  • Added first-load tracking to prevent duplicate data loading
  • Updated refresh logic to conditionally skip initial load for virtualized grids
  • Improved performance by eliminating redundant initial data fetching

@dariatiurina dariatiurina added this to the 11.0-preview1 milestone Sep 10, 2025
Co-authored-by: Copilot <[email protected]>
Copy link
Member

@ilonatommy ilonatommy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a unit test for this?

@@ -155,6 +155,8 @@ public partial class QuickGrid<TGridItem> : IAsyncDisposable
// If the QuickGrid is disposed while the JS module is being loaded, we need to avoid calling JS methods
private bool _wasDisposed;

private bool _firstRefreshDataAsync = true;
Copy link
Member

@ilonatommy ilonatommy Sep 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Added a _firstRefreshDataAsync flag to the QuickGrid class to track whether the initial data load has occurred."

Can we simplify it to _shouldSkipDataLoad? Or _shouldSkipDataRefresh.

Suggested change
private bool _firstRefreshDataAsync = true;
private bool _shouldSkipDataLoad = true;

@dariatiurina dariatiurina force-pushed the 55979-items-provider-virtualize branch from f95786c to bad1df2 Compare September 12, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

QuickGrid ItemsProvider called first time with Count=null when using Virtualize=true
3 participants