Virtual Sources
- 3 minutes to read
#Overview
The InfiniteAsyncSource is an asynchronous virtual source that allows you to bind the GridControl to any data source even if the total record count is unknown. The GridControl only requests the top records, and you can specify required data operations supported by the data source.
#Complete Example
#Bind to any Data Source
You can use the InfiniteAsyncSource to connect the GridControl to any data source: REST Services, NoSQL Databases, Custom WCF Services, EntityFramework, or any other ORM.
#Minimum Requirement
The data source should conatain an API to fetch portions of data consecutively (for example, Skip and Take). Virtual sources do not require a total item count, and sorting, filtering, and summary calculation operations are optional.
#Enable Features
The GridControl bound to a virtual source only requests the top records. You can specify which data operations are allowed (for example, a user can sort by columns A, C, and D, and the Fixed Summary Panel can display the last created object’s date and time).
Virtual sources allow you to control requests that the GridControl sends to a service or database. You can exclude non-optimal queries to avoid database overload. The GridControl hides all UI elements for non-supported operations.
Refer to the following help topic for more information: Virtual Sources Limitations.
#Workflow
The InfiniteAsyncSource raises events in the UI Thread and uses tasks to process data in parallel working threads. Specify tasks in the event handlers to obtain rows, summaries, and so on.
The image below illustrates the workflow:
- The virtual source raises the InfiniteAsyncSource.GetTotalSummaries event. Handle this event and process summaries to show them in the GridControl.
- The virtual source raises the InfiniteAsyncSource.FetchRows event to get the first portion of data.
- When a user scrolls the grid, the virtual source raises the InfiniteAsyncSource.FetchRows event to get the next portion of data.
- When a user opens a column’s drop-down filter, the virtual source raises the InfiniteAsyncSource.GetUniqueValues event to get unique values and show them in the drop-down filter.
#Tutorial Steps
This step-by-step tutorial demonstrates how to use the InfiniteAsyncSource.
-
Create a virtual source and fetch rows from a service.
Step 2: Enable Sort Operations
Implement sort operations in the virtual source and enable them in the GridControl.
Step 3: Enable Filter Operations
Implement filter operations in the virtual source and enable them in the GridControl.
-
Get summaries and display them in the GridControl.