Spry.Data.PagedView Sample

This sample shows you how to use the Spry.Data.PagedView class to control the paging of data in a data set. The PagedView class is a special type of data set that listens to another data set and knows how to extract data out of the other data set whenever it changes. Because it is a data set, you use it within spry:regions to present a paged view of the data. There are special methods on the PagedView class that allow you to jump to random pages, or display a page that contains a specific row of data. Because the PagedView extracts its data from the data set it depends on, the ds_RowID value for each row in the PagedView is identical to the ds_RowID of the corresponding row in the data set it depends on.

The example below displays the cities for a given state as a set of pages. You can use the "State" select to dynamically change the data that is being paged. You can also type into the filter textfield to cause changes in the data that is being paged.

The example also has some buttons (First, Prev, Next, Last, etc) and textfields that allow you to dynamically change the page being viewed as well as other paging parameters with the Spry.Data.PagedView class.


 

Choose a State: Enter the Name of a City: Contains:

 


{ds_PageNumber} {ds_PageNumber}

{ds_PageFirstItemNumber}-{ds_PageLastItemNumber} {ds_PageFirstItemNumber}-{ds_PageLastItemNumber}

Page {ds_PageNumber} of {ds_PageCount} - Items {ds_PageFirstItemNumber} - {ds_PageLastItemNumber} of {ds_UnfilteredRowCount}

No matching data found!


Options for the Spry.DataPagedView constructor:

Option Name Description
forceFullPages Boolean. If true, and there is more than one page of data, force the last page of data to contain a full set of data. Note that this could cause some items to appear on both the last and next to last pages.
pageSize Integer. The max number of items in a page. Default is 10.
setCurrentRowOnPageChange Boolean. If true, the paged view will check to see if the data set's current row is in the current page. If it isn't, then it will force the current row of the data set to be the first item in the page.
useZeroBasedIndexes Boolean. If true the caller will pass page indexes to the various paging functions that are between zero and n-1, where n is the total number of rows in the data set. The default is false, so page numbers are between 1 and n.

Methods on the Spry.Data.PagedView class:

Method Name Description
getPageCount() Returns the number of pages that are necessary to accomodate all of the data. This count is based on the page size and number of rows of data in the data set.
getCurrentPage() Returns the page number/index for the data that is returned by a call to getData(). By default, the number returned by this method will be between 1 and the page count number. If the use useZeroBasedIndexes constructor option was set to true, this method will return a number between zero and pageCount minus one.
goToPage(pageIndex) Filter the data so that only rows associated with the specified page index are available via getData().
goToPageContainingRowID(rowID) Filter the data so that only rows on the same page as the row with the specified rowID are available.
goToPageContainingRowNumber(rowNumber) Filter the data so that only rows on the same page as the row with the specified row number are available.
goToPageContainingItemNumber(itemNumber) Filter the data so that only rows on the same page as the row with the specified item number are available.
firstPage() Filter the data set so that only rows in the first page are available.
lastPage() Filter the data set so that only rows in the last page are available.
previousPage() Filter the data set so that only rows in the previous page are available.
nextPage() Filter the data set so that only rows in the next page are available.
getPageForRowID(rowID) Returns the index of the page that contains the row with the given ds_RowID.
getPageForRowNumber(rowNumber) Returns the index of the page that contains the specified row number.
getPageForItemNumber(itemNumber) Returns the index of the page that contains the specified item number.
setPageSize(pageSize) Sets the maximum number of rows that can appear on any page. If zero, turns off paging.

Spry.Data.PagedView data references available in spry:region and spry:detailregion:

Data Reference Description
{ds_PageNumber} The current page index. By default this will be a number between 1 and ds_PageCount. If the useZeroBasedIndexes constructor option was set to true, this will be a number between 1 and ds_PageCount minus one.
{ds_PageSize} The maximum number of items that can be in a page.
{ds_PageCount} The total number of pages required to display all of the data.
{ds_PageItemRowNumber} The unfiltered row index for the current row being processed.
{ds_PageItemNumber} The unfiltered item number for the current row being processed. This is the unfiltered row index of the row plus one.
{ds_PageFirstItemNumber} The item number for the first row displayed in the current page.
{ds_PageLastItemNumber} The item number for the last row displayed in the current page.
{ds_PageItemCount} The total number of items in the current page.
{ds_PageTotalItemCount} The total number of items in all pages.
{ds_UnfilteredRowCount} The total number of rows in the data set.
{ds_CurrentRowID} For the PagedView, this is *always* the ID of the first row in the current page.
{ds_RowID} The row id for the row being processed.
{ds_CurrentRowNumber} For the PagedView, this is *always* zero, which is the index of the first row in the current page.
{ds_RowNumber} This is the row index, of the row being processed, in the current page.

Spry.Data.PagedView.PageInfo data references available in spry:region and spry:detailregion:

Data Reference Description
{ds_PageCount} The total number of pages in the paged view.
{ds_PageNumber} The page number within the paged view.
{ds_PageSize} The maximum number of items that can be in a page.
{ds_PageFirstItemNumber} The number of the first item in the page.
{ds_PageLastItemNumber} The number of the last item in the page.
{ds_PageItemCount} The number of items in the page.
{ds_PageTotalItemCount} The total number of items from all pages.