Data Centric Functions
Paging
By default, the Get<DataType>Xml function retrieves all the data items of a specific data type. If the number of items is great, it makes sense to retrieve and render the items in portions.
Say, you have a data type that contains your contacts and the list exceeds 1000 entries. You can retrieve 20 entries at a time and allow the user the user to select which group of 20 entries to show, i.e. select a page.
The following parameters allows you to set the number of items to retrieve at a time and select the page as well as provide information about paging such as how many pages it splits into, what page number is currently in use etc.
- Page size [PageSize]: (Int32) The number of items to display on one page – the maximum number of elements to return.
- Page number[PageNumber]: (Int32) If the number of data elements exceed the page size you can use paging to move to the other pages.
- Include paging info [IncludePagingInfo]: (Boolean) When selected, the data XML will be preceded by a <PagingInfo /> element detailing number of pages, items and more.
The last parameter returns XML similar to:
<PagingInfo CurrentPageNumber="1" TotalPageCount="1" TotalItemCount="3" ShownItemsCount="3" MaximumItemsPerPage="1000" CurrentItemNumberStart="1" CurrentItemNumberEnd="3" xmlns=""/>
Listing 3: Paging Info XML
Its attributes gives detailed information on paging:
- CurrentPageNumber: What page number is currently in use (set in the PageNumber parameter)
- TotalPageCount: How many pages data is split into
- TotalItemCount: How many items the data type contains
- ShownItemsCount: How many items is actually shown on a page (which can be fewer than the maximum, e.g. on the last page)
- MaximumItemsPerPage: How many items are supposed to be shown on one page at maximum(set in the PageSize parameter)
- CurrentItemNumberStart: The item number the current page starts with
- CurrentItemNumberEnd: The item number the current page ends with
For hands-on experience on paging, please refer to “Sorting and Paging”.