Programmatic Paging
Programmatic paging could be done with the help of the public paging API that RadDataServiceDataSource.DataView provides. The DataView property implements the IPagedCollectionView interface which contains all paging methods and properties.
Example 1: The IPagedCollectionView interface
public interface IPagedCollectionView
{
bool CanChangePage { get; }
bool IsPageChanging { get; }
int ItemCount { get; }
int PageIndex { get; }
int PageSize { get; set; }
int TotalItemCount { get; }
event EventHandler<EventArgs> PageChanged;
event EventHandler<PageChangingEventArgs> PageChanging;
bool MoveToFirstPage();
bool MoveToLastPage();
bool MoveToNextPage();
bool MoveToPage(int pageIndex);
bool MoveToPreviousPage();
}
Public Interface IPagedCollectionView
ReadOnly Property CanChangePage() As Boolean
ReadOnly Property IsPageChanging() As Boolean
ReadOnly Property ItemCount() As Integer
ReadOnly Property PageIndex() As Integer
Property PageSize() As Integer
ReadOnly Property TotalItemCount() As Integer
Event PageChanged As EventHandler(Of EventArgs)
Event PageChanging As EventHandler(Of PageChangingEventArgs)
Function MoveToFirstPage() As Boolean
Function MoveToLastPage() As Boolean
Function MoveToNextPage() As Boolean
Function MoveToPage(ByVal pageIndex As Integer) As Boolean
Function MoveToPreviousPage() As Boolean
End Interface
Example 2 shows how to use the DataView in order to set the last page as the current page.
Example 2: Moving to the last page
private void MoveToLastPage(RadDataServiceDataSource dataSource)
{
dataSource.DataView.MoveToLastPage();
}
Private Sub MoveToLastPage(ByVal dataSource As RadDataServiceDataSource)
dataSource.DataView.MoveToLastPage()
End Sub
When a page change is requested, a trip to the server will be made regardless of the AutoLoad setting. When filtering, sorting or grouping occurs, a trip to the server is made, the DataView is re-created and always returns to the first page.