Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TPagedList

TComponent
   |
   --TList
      |
      --TPagedList

Direct Known Sub-classes:

TPagedList class

TPagedList implements a list with paging functionality.

TPagedList works in one of two modes, managed paging or customized paging, specified by CustomPaging.

  • Managed paging (CustomPaging=false) : the list is assumed to contain all data and it will manage which page of data are available to user.
  • Customized paging (CustomPaging=true) : the list is assumed to contain only one page of data. An OnFetchData event will be raised if the list changes to a different page. Developers can attach a handler to the event and supply the needed data. The event handler can be written as follows,
    1. public function fetchData($sender,$param)
    2. {
    3. $offset=$param->Offset; // beginning index of the data needed
    4. $limit=$param->Limit; // maximum number of data items needed
    5. // get data according to the above two parameters
    6. $param->Data=$data;
    7. }
Data in TPagedList can be accessed like an integer-indexed array and can be traversed using foreach. For example,
  1. $count=$list->Count;
  2. for($index=0;$index<$count;++$index)
  3. echo $list[$index];
  4. foreach($list as $index=>$item) // traverse each item in the list

The PageSize property specifies the number of items in each page. To access different page of data in the list, set CurrentPageIndex or call nextPage(), previousPage(), or gotoPage(). The total number of pages can be obtained by PageCount.

Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Constructor Summary
public
__construct Array
Constructor.

Method Summary
integer
integer
boolean
boolean
boolean
Iterator
integer
integer
integer
integer|boolean
gotoPage ( integer $pageIndex)
Changes to a page with the specified page index.
integer
indexOf ( mixed $item)
mixed
itemAt ( integer $index)
Returns the item at the specified offset.
integer|boolean
Switches to the next page.
boolean
offsetExists ( integer $offset)
Returns whether there is an item at the specified offset.
mixed
offsetGet ( integer $offset)
Returns the item at the specified offset.
void
Raises OnFetchData event.
void
Raises OnPageIndexChanged event.
integer|boolean
Switches to the previous page.
void
setCurrentPageIndex ( integer $value)
void
setCustomPaging ( boolean $value)
void
setPageSize ( integer $value)
void
setVirtualCount ( integer $value)
array
toArray ()
Methods Inherited From TList
TList::add(), TList::clear(), TList::contains(), TList::copyFrom(), TList::count(), TList::getCount(), TList::getIterator(), TList::getReadOnly(), TList::indexOf(), TList::insertAt(), TList::itemAt(), TList::mergeWith(), TList::offsetExists(), TList::offsetGet(), TList::offsetSet(), TList::offsetUnset(), TList::remove(), TList::removeAt(), TList::setReadOnly(), TList::toArray()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constructor Details

__construct

public __construct Array

Constructor.


Method Details

getCount

public integer getCount ()

Output
integer the number of items in current page
Exception

getCurrentPageIndex

public integer getCurrentPageIndex ()

Output
integer current page index. Defaults to 0.
Exception

getCustomPaging

public boolean getCustomPaging ()

Output
boolean whether to use custom paging. Defaults to false.
Exception

getIsFirstPage

public boolean getIsFirstPage ()

Output
boolean whether the current page is the first page
Exception

getIsLastPage

public boolean getIsLastPage ()

Output
boolean whether the current page is the last page
Exception

getIterator

public Iterator getIterator ()

Output
Iterator iterator
Exception

getPageCount

public integer getPageCount ()

Output
integer number of pages, -1 if under custom paging mode and VirtualCount is not set.
Exception

getPageSize

public integer getPageSize ()

Output
integer number of items in each page. Defaults to 10.
Exception

getVirtualCount

public integer getVirtualCount ()

Output
integer user-assigned number of items in data source. Defaults to 0.
Exception

gotoPage

public integer|boolean gotoPage (integer $pageIndex )

Changes to a page with the specified page index.

Input
integer$pageIndexpage index
Output
integer|boolean the new page index, false if page index is out of range.
Exception

indexOf

public integer indexOf (mixed $item )

Input
mixed$itemthe item
Output
integer the index of the item in the list (0 based), -1 if not found.
Exception

itemAt

public mixed itemAt (integer $index )

Returns the item at the specified offset.

This method is exactly the same as offsetGet.

Input
integer$indexthe index of the item
Output
mixed the item at the index
Exception
throwsTInvalidDataValueException if the index is out of the range

nextPage

public integer|boolean nextPage ()

Switches to the next page.

Output
integer|boolean the new page index, false if next page is not available.
Exception

offsetExists

public boolean offsetExists (integer $offset )

Returns whether there is an item at the specified offset.

This method is required by the interface ArrayAccess.

Input
integer$offsetthe offset to check on
Output
Exception

offsetGet

public mixed offsetGet (integer $offset )

Returns the item at the specified offset.

This method is required by the interface ArrayAccess.

Input
integer$offsetthe offset to retrieve item.
Output
mixed the item at the offset
Exception
throwsTInvalidDataValueException if the offset is invalid

onFetchData

public void onFetchData (TPagedListFetchDataEventParameter $param )

Raises OnFetchData event.

This event is raised each time when the list changes to a different page and needs the new page of data. This event can only be raised when CustomPaging is true.

Input
TPagedListFetchDataEventParameter$paramevent parameter
Output
Exception

onPageIndexChanged

public void onPageIndexChanged (TPagedListPageChangedEventParameter $param )

Raises OnPageIndexChanged event.

This event is raised each time when the list changes to a different page.

Input
TPagedListPageChangedEventParameter$paramevent parameter
Output
Exception

previousPage

public integer|boolean previousPage ()

Switches to the previous page.

Output
integer|boolean the new page index, false if previous page is not available.
Exception

setCurrentPageIndex

public void setCurrentPageIndex (integer $value )

Input
integer$valuecurrent page index
Output
Exception
throwsTInvalidDataValueException if the page index is out of range

setCustomPaging

public void setCustomPaging (boolean $value )

Input
boolean$valuewhether to allow custom paging
Output
Exception

setPageSize

public void setPageSize (integer $value )

Input
integer$valuenumber of items in each page
Output
Exception

setVirtualCount

public void setVirtualCount (integer $value )

Input
integer$valueuser-assigned number of items in data source
Output
Exception

toArray

public array toArray ()

Output
array the list of items in array
Exception