Spry Paged View Data Set

The Paged View Data Set is a data set made from a master data set allows for simple paging in Spry. Refer to the overview document and the extensive sample file.

Method Name Description
Paged View data set constructor Sets up the Paged View data set.
firstPage() Filter the data set so that only rows in the first page are available.
getCurrentPage() Returns the number of the current page.
getPageCount() Returns the total number of pages currently set.
getPageForItemNumber(itemNumber) Returns the index of the page that contains the specified item number.
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.
getPagingInfo() A special data set that data references for common paging patterns.
goToPage(pageIndex) Filter the data so that only rows associated with the specified page index are available via getData().
goToPageContainingItemNumber(itemNumber) Filter the data so that only rows on the same page as the row with the specified item number are available.
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.
lastPage() Filter the data set so that only rows in the last page are available.
nextPage() Filter the data set so that only rows in the next page are available.
previousPage() Filter the data set so that only rows in the previous page are available.
setPageSize(pageSize) Sets the maximum number of rows that can appear on any page. If zero, turns off paging.
Data References A list of data references available to the Paged View data set.

Definitions

Here are the terms used in the Paged View data set.

Term Definition
index  
item number  
row number  
row ID  

 

PagedView Data Set constructor

The Paged View data set is a special data set because it gets its data from an existing Spry data set. The Paged View data set then computes the paging information from this parent data set. Therefore, the page must have an existing data set to work properly. The name of this data set is used in the Paged View constructor.

To use the Paged View data set, the Paged View javascript file must be included in the head of the page, below the SpryData.js script.

<script language="JavaScript" type="text/javascript" src="../../includes/SpryData.js"></script>
<script language="JavaScript" type="text/javascript" src="../../includes/SpryPagedView.js"></script>

A basic Paged View constructor looks like this:

var pv1 = new Spry.Data.PagedView(datasetname, {options});

As with other Spry data sets, the var 'pv1' is the name of the data set that will be used in the Spry regions. The datasetname is the name of the parent data set. You generally do not wrap this name in quotes.

Paged View data set options

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.
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.

By default, the Paged View data set will use 10 rows per page. To change this, set the 'pageSize' option in the constructor.

var pv1 = new Spry.Data.PagedView(ds1, {pageSize:25, forceFullPages:true, setCurrentRowOnPageChange:false, useZeroBasedIndexes:true });

firstPage

datasetname.firstPage();

Description

Sets the Paged View Data Set to the first page of data.

This only works with a Paged View Data Set.

Example

    <input type="button" value="First" onclick="pvCities.firstPage();" />

getCurrentPage

datasetname.getCurrentPage();

Description

Returns the page number/index for the data that is returned by a call to getData(). This is the page number that contains the row with current row value. 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.

This only works with a Paged View Data Set.

Example

<script>
function getPage(){
var x = pv1.getCurrentPage();
} </script>

getPageForRowID

datasetname.getPageForRowID(rowID);

Description

Returns the page number that contains the item with the specified rowID.

This only works with a Paged View Data Set.

Example

   x = pv1.getPageForRowID('{ds_rowID}');

getPageForRowNumber

datasetname.getPageForRowNumber(rowNumber);

Description

Returns the page number that contains the item with the specified row number.

This only works with a Paged View Data Set.

Example

    x = pv1.getPageForRoNumber(25);

getPageForItemNumber

datasetname.getPageForItemNumber(itemNumber);

Description

Returns the page number that contains the item with the specified item number.

This only works with a Paged View Data Set.

Example

   x = pv1.getPageForItemNumber(20);

getPageCount

datasetname.getPageCount();

Description

Returns the number of pages in the Paged View data set. This number can change depending on the number of rows and the number of rows per page.

This only works with a Paged View Data Set.

Example

<script>
function getPages(){
var x = pv1.getPageCount();
} </script>

getPagingInfo()

getPagingInfo is a special data set that creates data references that are using in common paging patterns. It is used to generate things like: "Go to Page: 1 2 3 4" and "Page 3 of 4". This data set is declared in the head, below the Paged View data set constructor. This data set only creates the following data references:

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.

Example

...  
   var pv1 = new Spry.Data.PagedView(ds1,{pageSize:20});
   var pagingInfo = pv1.getPagingInfo();
</head>

<div spry:region="pagingInfo">
{ds_PageNumber} of {ds_PageCount}
</div>

goToPage()

datasetname.goToPage(pageIndex)

Description

Sets the page to the page that contains the specified pageIndex.

Arguments

pageIndex

Example

<input type="button" value="Go To Page 6" onclick="pv1.goToPage(6);" />

goToPageContainingItemNumber(itemNumber)

datasetname.goToPageContainingItemNumber(pageIndex)

Description

Sets the page to the page that contains the specified item number.

Arguments

itemNumber

Example

<input type="button" value="Go To Page 6" onclick="pv1.goToPageContainingItemNumber(6);" />

goToPageContainingRowID()

datasetname.goToPageContainingRowID(rowID)

Description

Sets the page to the page that contains the specified pageIndex.

Arguments

rowID

Example

<input type="button" value="Go To Page 6" onclick="pv1.goToPageContainingRowID(6);" />

goToPageContainingRowNumber(rowNumber)

datasetname.goToPageContainingRowNumber(rowNumber)

Description

Sets the page to the page that contains the specified pageIndex.

Arguments

rowNumber

Example

<input type="button" value="Go To Page 6" onclick="pv1.goToPageContainingRowNumber(6);" />

lastPage

datasetname.lastPage();

Description

Sets the Paged View Data Set to the last page of data.

This only works with a Paged View Data Set.

Example

    <input type="button" value="Last" onclick="pv1.lastPage();" />
  

nextPage

datasetname.nextPage();

Description

Sets the Paged View Data Set to the next page of data.

This only works with a Paged View Data Set.

Example

    <input type="button" value="Next" onclick="pv1.nextPage();" />
  

previousPage

datasetname.previousPage();

Description

Sets the Paged View Data Set to the previous page of data.

This only works with a Paged View Data Set.

Example

    <input type="button" value="Previous" onclick="pvCities.previousPage();" />
  

setPageSize

datasetname.setPageSize(number);

Description

Sets the number of items that will be shown per page.

This only works with a Paged View Data Set.

Example

  <input type="button" value="Show 20 Records per Page" onclick="pvCities.setPageSize(20);" />
  

Data References

Since the Paged View data set is still a Spry data set, these data references can be used in the same way as other Spry data references. They must be within a Spry region or detail region and the Paged View data set name must be listed in the Spry region attribute.

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.

Copyright © 2007. Adobe Systems Incorporated.
All rights reserved.