MVVM Support
This topic will go through the approach of using RadVirtualGrid in MVVM scenarios. This can be achieved by benefiting from the DataProvider mechanism of the control. More information on this matter can be found in the Getting Started and Custom DataProvider topics.
Defining the business model
Firstly, we need an object model that will be used to populate RadVirtualGrid with data. For this purpose, the following Club object is defined.
Example 1: Defining the Club object
Implementing a custom DataProvider
The next step is to define a custom DataProvider that handles some specific scenarios. It demonstrates how the selection of the control can be persisted when sorting or filtering. Note, that by default the selection is being cleared when processing these operations. Also, the example demonstrates how to hide a given column, define a custom editor, set a given column to be readonly and apply a custom header.
Example 2: Implementing a Custom DataProvider
Defining the View Model
The following code snippet demonstrates how the custom DataProvider can be exposed by a view model.
Example 2: Defining the View Model
Populate RadVirtualGrid
This section shows how the View Model can be set to be the DataContext of RadVirtualGrid and how its DataProvider property can be bound to the custom DataProvider.