On-demand loading
GridControlRows, groups, totals and exports fetched from a provider as they are needed, never all at once.
Overview
An ItemsProvider replaces DataSource with a delegate the grid calls whenever it needs rows: the first
window, a scroll past what is loaded, a new sort or search, an export. Each GridItemsRequest says what is wanted
(Purpose), where in the result it starts (StartIndex, Count) and the current
Query: sorts, filters, search text, group fields and the aggregates to compute. The provider translates that into its
own LINQ or SQL and answers with a GridItemsResult of items and the total count. The grid keeps only a few recent
ranges in memory.
With EnableProviderGrouping the same delegate also serves the group tree. Groups asks for the top-level
groups, GroupChildren for the groups under one of them and GroupItems for the rows under the innermost,
each with the parent keys in GroupRequest. Groups start collapsed (ProviderGroupsInitiallyCollapsed), so
opening one is what sends its request; ProviderGroupPageSize and ProviderGroupItemPageSize cap each page,
and the grid adds a Load more row while the provider reports HasMore. Group counts and aggregates come from
the provider too, so captions and footers are right before any row is loaded.
ExportProviderQueryAsync exports the whole current query rather than the loaded window: it pages through
Export requests of ProviderExportPageSize rows, reports each page through
ProviderExportProgressChanged, and CancelProviderExport stops it. Column filters travel in the same request
as Query.Filters; this example leaves column filtering off because its provider does not translate them.
Examples
#Twelve thousand orders, loaded group by group
The orders sit in an in-memory list behind a 90 ms delay (60 ms for export pages) and stand in for a database. Open a region to fetch its categories, open a category to fetch its first 75 rows, and use Load more for the rest; the line under the grid counts the requests and names the last one. Sorting a column or typing in the search box starts a new query. Export all to CSV writes every order that matches the search, 400 at a time, with progress and a Cancel.
| Region | Category | Order | Customer | Date | Qty | Amount |
|---|---|---|---|---|---|---|
| No records to display | ||||||
Waiting for the first request…
Documentation
GridItemsRequest, GridItemsResult, GridProviderGroup and the grid's provider parameters are still to be written up from Grid/GridItemsProvider.cs, Grid/GridControl.ItemsProvider.cs, Grid/GridControl.ProviderGrouping.cs and Grid/GridControl.ProviderExport.cs.