diff --git a/src/Core/Components/DataGrid/FluentDataGrid.razor.cs b/src/Core/Components/DataGrid/FluentDataGrid.razor.cs index 4bb434e16c..176da65b0f 100644 --- a/src/Core/Components/DataGrid/FluentDataGrid.razor.cs +++ b/src/Core/Components/DataGrid/FluentDataGrid.razor.cs @@ -372,7 +372,7 @@ public partial class FluentDataGrid : FluentComponentBase, IHandleEve // Returns Loading if set (controlled). If not controlled, // we assume the grid is loading until the next data load completes - internal bool EffectiveLoadingValue => Loading ?? ItemsProvider is not null; + internal bool EffectiveLoadingValue => Loading ?? (ItemsProvider is not null); private ElementReference? _gridReference; //private DotNetObjectReference? _dotNetObjectReference; @@ -423,6 +423,7 @@ public partial class FluentDataGrid : FluentComponentBase, IHandleEve private GridItemsProvider? _lastAssignedItemsProvider; private CancellationTokenSource? _pendingDataLoadCancellationTokenSource; + private bool _isFirstVirtualizeProviderCall = true; private Exception? _lastError; private GridItemsProviderRequest? _lastRequest; @@ -865,9 +866,15 @@ private async Task RefreshDataCoreAsync() _lastRefreshedPaginationState = Pagination; // Debounce the requests. This eliminates a lot of redundant queries at the cost of slight lag after interactions. - // TODO: Consider making this configurable, or smarter (e.g., doesn't delay on first call in a batch, then the amount - // of delay increases if you rapidly issue repeated requests, such as when scrolling a long way) - await Task.Delay(100); + // Skip the delay on the first call to avoid unnecessary lag on initial load. + if (_isFirstVirtualizeProviderCall) + { + _isFirstVirtualizeProviderCall = false; + } + else + { + await Task.Delay(100); + } if (request.CancellationToken.IsCancellationRequested) {