PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TPagedList

TPagedList class

TPagedList implements a list with paging functionality.

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

  • Managed paging (setCustomPaging CustomPaging=false) : the list is assumed to contain all data and it will manage which page of data are available to user.
  • Customized paging (setCustomPaging CustomPaging=true) : the list is assumed to contain only one page of data. An onFetchData 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 setPageSize PageSize property specifies the number of items in each page. To access different page of data in the list, set setCurrentPageIndex CurrentPageIndex or call TPagedList::nextPage(), TPagedList::previousPage(), or TPagedList::gotoPage(). The total number of pages can be obtained by getPageCount() PageCount.

TComponent
Extended by TList implements IteratorAggregate, ArrayAccess, Countable
Extended by TPagedList

Direct known subclasses

TSqlMapPagedList
Package: System\Collections
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at Collections/TPagedList.php
Methods summary
public
# __construct( array|Iterator $data = null, boolean $readOnly = false )

Constructor.

Constructor.

Parameters

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

Throws

TInvalidDataTypeException
If data is not null and neither an array nor an iterator.

Overrides

TList::__construct()
public boolean
# getCustomPaging( )

Returns

boolean
whether to use custom paging. Defaults to false.
public
# setCustomPaging( boolean $value )

Parameters

$value
boolean
whether to allow custom paging
public integer
# getPageSize( )

Returns

integer
number of items in each page. Defaults to 10.
public
# setPageSize( integer $value )

Parameters

$value
integer
number of items in each page
public integer
# getCurrentPageIndex( )

Returns

integer
current page index. Defaults to 0.
public
# setCurrentPageIndex( integer $value )

Parameters

$value
integer
current page index

Throws

TInvalidDataValueException
if the page index is out of range
public
# onPageIndexChanged( TPagedListPageChangedEventParameter $param )

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

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

Parameters

$param
TPagedListPageChangedEventParameter
event parameter
public
# 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 setCustomPaging CustomPaging is true.

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 setCustomPaging CustomPaging is true.

Parameters

$param
TPagedListFetchDataEventParameter
event parameter
public integer|boolean
# gotoPage( integer $pageIndex )

Changes to a page with the specified page index.

Changes to a page with the specified page index.

Parameters

$pageIndex
integer
page index

Returns

integer|boolean
the new page index, false if page index is out of range.
public integer|boolean
# nextPage( )

Switches to the next page.

Switches to the next page.

Returns

integer|boolean
the new page index, false if next page is not available.
public integer|boolean
# previousPage( )

Switches to the previous page.

Switches to the previous page.

Returns

integer|boolean
the new page index, false if previous page is not available.
public integer
# getVirtualCount( )

Returns

integer
user-assigned number of items in data source. Defaults to 0.
public
# setVirtualCount( integer $value )

Parameters

$value
integer
user-assigned number of items in data source
public integer
# getPageCount( )

Returns

integer
number of pages, -1 if under custom paging mode and setVirtualCount VirtualCount is not set.
public boolean
# getIsFirstPage( )

Returns

boolean
whether the current page is the first page
public boolean
# getIsLastPage( )

Returns

boolean
whether the current page is the last page
public integer
# getCount( )

Returns

integer
the number of items in current page

Overrides

TList::getCount()
public Iterator
# getIterator( )

Returns

Iterator
iterator

Overrides

TList::getIterator()
public mixed
# itemAt( integer $index )

Returns the item at the specified offset. This method is exactly the same as TPagedList::offsetGet().

Returns the item at the specified offset. This method is exactly the same as TPagedList::offsetGet().

Parameters

$index
integer
the index of the item

Returns

mixed
the item at the index

Throws

TInvalidDataValueException
if the index is out of the range

Overrides

TList::itemAt()
public integer
# indexOf( mixed $item )

Parameters

$item
mixed
the item

Returns

integer
the index of the item in the list (0 based), -1 if not found.

Overrides

TList::indexOf()
public boolean
# offsetExists( integer $offset )

Returns whether there is an item at the specified offset. This method is required by the interface ArrayAccess.

Returns whether there is an item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to check on

Returns

boolean

Overrides

TList::offsetExists()
public mixed
# offsetGet( integer $offset )

Returns the item at the specified offset. This method is required by the interface ArrayAccess.

Returns the item at the specified offset. This method is required by the interface ArrayAccess.

Parameters

$offset
integer
the offset to retrieve item.

Returns

mixed
the item at the offset

Throws

TInvalidDataValueException
if the offset is invalid

Overrides

TList::offsetGet()
public array
# toArray( )

Returns

array
the list of items in array

Overrides

TList::toArray()
Methods inherited from TList
add(), clear(), contains(), copyFrom(), count(), getReadOnly(), insertAfter(), insertAt(), insertBefore(), mergeWith(), offsetSet(), offsetUnset(), remove(), removeAt(), setReadOnly()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO