## Class TPagedList

Description

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,

        public function fetchData($sender,$param)
        {
          $offset=$param->Offset; // beginning index of the data needed
          $limit=$param->Limit;   // maximum number of data items needed
          // get data according to the above two parameters
          $param->Data=$data;
        }

Data in TPagedList can be accessed like an integer-indexed array and can be traversed using foreach. For example,

     $count=$list->Count;
     for($index=0;$index<$count;++$index)
         echo $list[$index];
     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
- version: $Id: TPagedList.php 1398 2006-09-08 19:31:03Z xue $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Collections/TPagedList.php (line 58)

    TComponent
       |
       --TList
          |
          --TPagedList

Direct descendents

Class | Description
--- | ---
TSqlMapPagedList | TSqlMapPagedList implements a list with paging functionality that retrieves data from a SqlMap statement.

Method Summary
TPagedList __construct ([array|Iterator $data = null], [boolean $readOnly = false])
integer getCount ()
integer getCurrentPageIndex ()
boolean getCustomPaging ()
boolean getIsFirstPage ()
boolean getIsLastPage ()
Iterator getIterator ()
integer getPageCount ()
integer getPageSize ()
integer getVirtualCount ()
integer|boolean gotoPage (integer $pageIndex)
integer indexOf (mixed $item)
mixed itemAt (integer $index)
integer|boolean nextPage ()
boolean offsetExists (integer $offset)
mixed offsetGet (integer $offset)
void onFetchData (TPagedListFetchDataEventParameter $param)
void onPageIndexChanged (TPagedListPageChangedEventParameter $param)
integer|boolean previousPage ()
void setCurrentPageIndex (integer $value)
void setCustomPaging (boolean $value)
void setPageSize (integer $value)
void setVirtualCount (integer $value)
array toArray ()
Methods
Constructor __construct (line 82)

Constructor.

- access: public

TPagedList __construct ([array|Iterator $data = null], [boolean $readOnly = false])

- array|Iterator $data: the intial data. Default is null, meaning no initialization.
- boolean $readOnly: whether the list is read-only. Always true for paged list.

Redefinition of:

TList::__construct()
  Constructor.

Redefined in descendants as:

- TSqlMapPagedList::__construct() : Create a new SqlMap paged list.

getCount (line 277)

- return: the number of items in current page
- access: public

integer getCount ()

Redefinition of:

TList::getCount()

getCurrentPageIndex (line 125)

- return: current page index. Defaults to 0.
- access: public

integer getCurrentPageIndex ()
getCustomPaging (line 90)

- return: whether to use custom paging. Defaults to false.
- access: public

boolean getCustomPaging ()
getIsFirstPage (line 261)

- return: whether the current page is the first page
- access: public

boolean getIsFirstPage ()
getIsLastPage (line 269)

- return: whether the current page is the last page
- access: public

boolean getIsLastPage ()

Redefined in descendants as:

- TSqlMapPagedList::getIsLastPage()

getIterator (line 293)

- return: iterator
- access: public

Iterator getIterator ()

Redefinition of:

TList::getIterator()
  Returns an iterator for traversing the items in the list.

getPageCount (line 245)

- return: number of pages, -1 if under custom paging mode and VirtualCount is not set.
- access: public

integer getPageCount ()
getPageSize (line 106)

- return: number of items in each page. Defaults to 10.
- access: public

integer getPageSize ()
getVirtualCount (line 227)

- return: user-assigned number of items in data source. Defaults to 0.
- access: public

integer getVirtualCount ()
gotoPage (line 167)

Changes to a page with the specified page index.

- return: the new page index, false if page index is out of range.
- access: public

integer|boolean gotoPage (integer $pageIndex)

- integer $pageIndex: page index

indexOf (line 323)

- return: the index of the item in the list (0 based), -1 if not found.
- access: public

integer indexOf (mixed $item)

- mixed $item: the item

Redefinition of:

TList::indexOf()

itemAt (line 311)

Returns the item at the specified offset.

This method is exactly the same as offsetGet.

- return: the item at the index
- access: public
- throws: TInvalidDataValueException if the index is out of the range

mixed itemAt (integer $index)

- integer $index: the index of the item

Redefinition of:

TList::itemAt()
  Returns the item at the specified offset.

nextPage (line 210)

Switches to the next page.

- return: the new page index, false if next page is not availabe.
- access: public

integer|boolean nextPage ()

Redefined in descendants as:

- TSqlMapPagedList::nextPage() : Switches to the next page.

offsetExists (line 338)

Returns whether there is an item at the specified offset.

This method is required by the interface ArrayAccess.

- access: public

boolean offsetExists (integer $offset)

- integer $offset: the offset to check on

Redefinition of:

TList::offsetExists()
  Returns whether there is an item at the specified offset.

offsetGet (line 350)

Returns the item at the specified offset.

This method is required by the interface ArrayAccess.

- return: the item at the offset
- access: public
- throws: TInvalidDataValueException if the offset is invalid

mixed offsetGet (integer $offset)

- integer $offset: the offset to retrieve item.

Redefinition of:

TList::offsetGet()
  Returns the item at the specified offset.

onFetchData (line 157)

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.

- access: public

void onFetchData (TPagedListFetchDataEventParameter $param)

- TPagedListFetchDataEventParameter $param: event parameter

onPageIndexChanged (line 145)

Raises OnPageIndexChanged event.

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

- access: public

void onPageIndexChanged (TPagedListPageChangedEventParameter $param)

- TPagedListPageChangedEventParameter $param: event parameter

previousPage (line 219)

Switches to the previous page.

- return: the new page index, false if previous page is not availabe.
- access: public

integer|boolean previousPage ()

Redefined in descendants as:

- TSqlMapPagedList::previousPage() : Switches to the previous page.

setCurrentPageIndex (line 134)

- access: public
- throws: TInvalidDataValueException if the page index is out of range

void setCurrentPageIndex (integer $value)

- integer $value: current page index

setCustomPaging (line 98)

- access: public

void setCustomPaging (boolean $value)

- boolean $value: whether to allow custom paging

Redefined in descendants as:

- TSqlMapPagedList::setCustomPaging()

setPageSize (line 114)

- access: public

void setPageSize (integer $value)

- integer $value: number of items in each page

setVirtualCount (line 235)

- access: public

void setVirtualCount (integer $value)

- integer $value: user-assigned number of items in data source

toArray (line 358)

- return: the list of items in array
- access: public

array toArray ()

Redefinition of:

TList::toArray()

#### Inherited Methods

Inherited From TList

> TList::__construct()
> 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()

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()

Documentation generated on Sun, 14 Jan 2007 21:43:43 -0500 by phpDocumentor 1.3.0RC4