Async ItemsProvider & Database Query Pushdown

Remote Provider

When managing enterprise datasets with hundreds of thousands of records, loading all rows into in-memory Blazor collections is inefficient. The ItemsProvider architecture provides an asynchronous, on-demand callback delegate (GridItemsProvider<T>) that requests only the slice of records required by the viewport.

Filter expressions, search phrases, sort orders, and pagination offsets are passed directly into the provider request, enabling 100% database query pushdown with zero memory consumption on the Blazor server.

Live Demo

Remote Search: Total Matches in DB: 0 | Active Window: 0 rows retrieved
Item Code Item Description Phase Code Phase Description Cost Category UOM Unit Price
No records to display
0 rows
@using Fx.ControlKit
@using Fx.ControlKit.Grid

<!-- ItemsProvider delegates viewport slices directly to backend queries -->
<GridControl TValue="EstimatingItemRecord"
             ItemsProvider="@_itemsProvider"
             Height="380px"
             AllowSorting="true"
             AllowSelection="true">
    <GridColumnsBase>
        <GridColumn Field="@nameof(EstimatingItemRecord.Item)" HeaderText="Item Code" Width="110px" />
        <GridColumn Field="@nameof(EstimatingItemRecord.ItemDesc)" HeaderText="Item Description" Width="260px" />
        <GridColumn Field="@nameof(EstimatingItemRecord.Phase)" HeaderText="Phase" Width="100px" />
        <GridColumn Field="@nameof(EstimatingItemRecord.Price)" HeaderText="Unit Price" Width="110px" Format="$#,##0.00" />
    </GridColumnsBase>
</GridControl>

@code {
    private GridItemsProvider<EstimatingItemRecord> _itemsProvider;

    protected override void OnInitialized()
    {
        _itemsProvider = async request =>
        {
            // Query SQLite or EF Core DB asynchronously
            var (rows, total) = await DbService.FetchSliceAsync(request.StartIndex, request.Count, request.CancellationToken);
            return GridItemsProviderResult.From(rows, total);
        };
    }
}

Feature Overview & Architecture Notes

ItemsProvider Implementation Guide

  • On-Demand Delegated Requests: The grid invokes the delegate passing a GridItemsProviderRequest<T> object with StartIndex, Count, and Sort parameters.
  • Pushdown SQL Execution: In a real database environment (e.g. SQLite, SQL Server, PostgreSQL), translate request.StartIndex into SQL OFFSET and Count into FETCH NEXT.
  • Total Count Contract: The provider returns a GridItemsProviderResult<T> containing the page of items and the TotalItemCount, allowing the grid scrollbar to reflect true dataset dimensions.

Request Parameters Contract

Member Type Description
StartIndex int Zero-based offset of the first record requested by the viewport.
Count int Number of records required to satisfy the scroll window plus overscan.
CancellationToken CancellationToken Enables early abort if the operator scrolls past quickly before results return.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.