Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Core/Components/DataGrid/FluentDataGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public partial class FluentDataGrid<TGridItem> : 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<Type>? _dotNetObjectReference;
Expand Down Expand Up @@ -423,6 +423,7 @@ public partial class FluentDataGrid<TGridItem> : FluentComponentBase, IHandleEve

private GridItemsProvider<TGridItem>? _lastAssignedItemsProvider;
private CancellationTokenSource? _pendingDataLoadCancellationTokenSource;
private bool _isFirstVirtualizeProviderCall = true;

private Exception? _lastError;
private GridItemsProviderRequest<TGridItem>? _lastRequest;
Expand Down Expand Up @@ -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)
{
Expand Down
Loading