Custom DataProvider
The DataProvider class exposes various methods and properties for extending and customizing the default behavior of its respective RadVirtualGrid control. Examples 1 and 2 demonstrate how you can create and apply a custom DataProvider.
Example 1: Defining a Custom DataProvider
public class CustomDataProvider: DataProvider
{
public CustomDataProvider(IEnumerable source) : base(source)
{
}
}
Public Class CustomDataProvider
Inherits DataProvider
Public Sub New(ByVal source As IEnumerable)
MyBase.New(source)
End Sub
End Class
Example 2: Applying the Custom DataProvider
this.VirtualGrid.DataProvider = new CustomDataProvider(Club.GetClubs());
Me.VirtualGrid.DataProvider = New CustomDataProvider(Club.GetClubs())
Figure 1: RadVirtualGrid with applied custom DataProvider
By inheriting the default DataProvider, the following methods and properties are exposed for customization.
A good example of how to override some of these members can be found in the "MVVM" demo from the SDK Samples Browser. The source code of the demo is also available in our GitHub repository.
Properties
InitialRowCount: If not overridden, gets the value that is set to the InitialRowCount property of RadVirtualGrid.
InitialColumnCount: If not overridden, gets the value that is set to the InitialRowCount property of RadVirtualGrid.
ShouldPushEditValueToGrid: When an editor is provided for the Editing operation, its edited value needs to be manually pushed to underlying source and to the grid through its PushCellValue method. If the ShouldPushEditValueToGrid property is overridden and returns a True value, updating the control with the edited property value will be done automatically.
DistinctValuesLimit: By default, its value is set to 1000. Through it, the maximum count of distinct values in the FilteringControl can be manipulated.
Methods
You can override each of the following methods in order to customize the behavior of the control when a certain operation is perfrormed either through the UI or programmatically.
OnCellEditEnded: The method that is called when the CellEditEnded event is raised.
OnCellValueNeeded: The method that is called when the CellValueNeeded event is raised.
OnEditorNeeded: The method that is called when the EditorNeeded event is raised.
OnEditorValueChanged: The method that is called when the EditorValueChanged event is raised.
OnHeaderValueNeeded: The method that is called when the HeaderValueNeeded event is raised.
DistinctValuesLoading: Occurs when the grid column distinct values are about to be loaded.
FilterOperatorsLoading: The method is invoked when the FilterOperators for a given column are being loaded.
SortDescriptorPreparing: The method is called when the SortDescriptors are being prepared.
SortDescriptorPrepared: The method is called when the SortDescriptors are prepared and a sort operation will occur.
OnSortingCompleted: The method is called when the sort operation is completed.
FilterDescriptorPreparing: The method is called when the FilterDescriptors are being prepared.
FilterDescriptorPrepared: The method is called when the FilterDescriptors are prepared and a filter operation will occur.
OnFilteringCompleted: The method is called when the filter operation is completed.
ApplyFilterDescriptor: Adds the filter descriptor to the Source QCV, which is the collection used for the data operations of the provider.
ApplySortDescriptor: Adds the sort descriptor to the Source QCV, which is the collection used for the data operations of the provider.
RemoveColumnFilter: Removes the given filter descriptor from the Source QCV.
IsColumnReadOnly: Determines whether a given column is ReadOnly.
RemoveItemsFromSource: Removes a set of items from the underlying source.