Skip to main content
A newer version of this page is available. .

Virtual Sources Overview

  • 3 minutes to read

Bind to any Data Source

You can connect the GridControl to any data source: REST Services, NoSQL Databases, Custom WCF Services, EntityFramework or any other ORM.

VirtualSourcesBindingToAnyData

Virtual Source Types

Infinite Source

The GridControl bound to InfiniteAsyncSource displays data with infinite scrolling:

VirtualSourcesTutorialAll

View Example Run Demo

Paged Source

The GridControl bound to PagedAsyncSource displays data in pages:

VirtualSourcesPagedAsync

View Example Run Demo

Minimum Requirement

A data source needs to expose an API to fetch portions of data consecutively (for example, Skip and Take or fetch a certain data page by page index). Total item count is not required; sorting, filtering, and summary calculation operations are optional.

Workflow

Async virtual sources raise events in the UI Thread and use tasks to process data in parallel Working Threads. You should provide tasks to these events to obtain summaries, rows, etc. Then the UI Thread gets data you fetched.

  1. (Optional step) The virtual source raises the InfiniteAsyncSource.GetTotalSummaries (or PagedAsyncSource.GetTotalSummaries) event. Handle this event and process summaries if you want to show them in the GridControl.
  2. The virtual source raises the InfiniteAsyncSource.FetchRows (or PagedAsyncSource.FetchPage) event to get the first portion of data.
  3. When end users navigate to the next page, the virtual source raises the InfiniteAsyncSource.FetchRows (or PagedAsyncSource.FetchPage) event to get the next portion of data.
  4. (Optional step) When users apply a filter, the virtual source raises the InfiniteAsyncSource.GetUniqueValues (or PagedAsyncSource.GetUniqueValues) event to get unique values and show them in a drop-down filter.

Enable Features

The GridControl bound to a virtual source only requests the top records or a certain page. You can specify which data operations are allowed, for example, an end user can sort by columns A, C, and D, and the Search Panel can filter data by the StartsWith criteria.

You can control requests that the GridControl sends to a service or database. This prevents overloading the database with non-optimal queries. The GridControl automatically hides all UI elements for non-supported operations.

Refer to the Virtual Sources Limitations topic to learn more.

MVVM Support

Virtual sources require handling events to load data and perform data operations like sorting, filtering, etc. You should create and configure them in code no matter what pattern you follow.

Virtual sources are designed to be a part of View. However, you can implement data operations at the View Model level with the following approaches:

  • In event handlers, transform source-specific objects (SortDefinition, SummaryDefinition, CriteriaOperator, etc.) into objects accepted by your View Model and invoke corresponding View Model methods.
  • If your View Model can work with source-specific objects, create a virtual source at the View Model level and handle the source events there.