PHP Class Prado\Collections\TPagedList

TPagedList implements a list with paging functionality. TPagedList works in one of two modes, managed paging or customized paging, specified by {@link setCustomPaging CustomPaging}. - Managed paging ({@link 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 ({@link setCustomPaging CustomPaging}=true) : the list is assumed to contain only one page of data. An {@link 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 {@link setPageSize PageSize} property specifies the number of items in each page. To access different page of data in the list, set {@link setCurrentPageIndex CurrentPageIndex} or call {@link nextPage()}, {@link previousPage()}, or {@link gotoPage()}. The total number of pages can be obtained by {@link getPageCount() PageCount}.
Since: 3.0
Author: Qiang Xue ([email protected])
Inheritance: extends TList
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( $data = null, $readOnly = false ) Constructor.
getCount ( ) : integer
getCurrentPageIndex ( ) : integer
getCustomPaging ( ) : boolean
getIsFirstPage ( ) : boolean
getIsLastPage ( ) : boolean
getIterator ( ) : Iterator
getPageCount ( ) : integer
getPageSize ( ) : integer
getVirtualCount ( ) : integer
gotoPage ( $pageIndex ) : integer | boolean Changes to a page with the specified page index.
indexOf ( $item ) : integer
itemAt ( $index ) : mixed Returns the item at the specified offset.
nextPage ( ) : integer | boolean Switches to the next page.
offsetExists ( $offset ) : boolean Returns whether there is an item at the specified offset.
offsetGet ( $offset ) : mixed Returns the item at the specified offset.
onFetchData ( $param ) Raises OnFetchData event.
onPageIndexChanged ( $param ) Raises OnPageIndexChanged event.
previousPage ( ) : integer | boolean Switches to the previous page.
setCurrentPageIndex ( $value )
setCustomPaging ( $value )
setPageSize ( $value )
setVirtualCount ( $value )
toArray ( ) : array

Method Details

__construct() public méthode

Constructor.
public __construct ( $data = null, $readOnly = false )

getCount() public méthode

public getCount ( ) : integer
Résultat integer the number of items in current page

getCurrentPageIndex() public méthode

public getCurrentPageIndex ( ) : integer
Résultat integer current page index. Defaults to 0.

getCustomPaging() public méthode

public getCustomPaging ( ) : boolean
Résultat boolean whether to use custom paging. Defaults to false.

getIsFirstPage() public méthode

public getIsFirstPage ( ) : boolean
Résultat boolean whether the current page is the first page

getIsLastPage() public méthode

public getIsLastPage ( ) : boolean
Résultat boolean whether the current page is the last page

getIterator() public méthode

public getIterator ( ) : Iterator
Résultat Iterator iterator

getPageCount() public méthode

public getPageCount ( ) : integer
Résultat integer number of pages, -1 if under custom paging mode and {@link setVirtualCount VirtualCount} is not set.

getPageSize() public méthode

public getPageSize ( ) : integer
Résultat integer number of items in each page. Defaults to 10.

getVirtualCount() public méthode

public getVirtualCount ( ) : integer
Résultat integer user-assigned number of items in data source. Defaults to 0.

gotoPage() public méthode

Changes to a page with the specified page index.
public gotoPage ( $pageIndex ) : integer | boolean
Résultat integer | boolean the new page index, false if page index is out of range.

indexOf() public méthode

public indexOf ( $item ) : integer
Résultat integer the index of the item in the list (0 based), -1 if not found.

itemAt() public méthode

This method is exactly the same as {@link offsetGet}.
public itemAt ( $index ) : mixed
Résultat mixed the item at the index

nextPage() public méthode

Switches to the next page.
public nextPage ( ) : integer | boolean
Résultat integer | boolean the new page index, false if next page is not available.

offsetExists() public méthode

This method is required by the interface \ArrayAccess.
public offsetExists ( $offset ) : boolean
Résultat boolean

offsetGet() public méthode

This method is required by the interface \ArrayAccess.
public offsetGet ( $offset ) : mixed
Résultat mixed the item at the offset

onFetchData() public méthode

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 {@link setCustomPaging CustomPaging} is true.
public onFetchData ( $param )

onPageIndexChanged() public méthode

This event is raised each time when the list changes to a different page.
public onPageIndexChanged ( $param )

previousPage() public méthode

Switches to the previous page.
public previousPage ( ) : integer | boolean
Résultat integer | boolean the new page index, false if previous page is not available.

setCurrentPageIndex() public méthode

public setCurrentPageIndex ( $value )

setCustomPaging() public méthode

public setCustomPaging ( $value )

setPageSize() public méthode

public setPageSize ( $value )

setVirtualCount() public méthode

public setVirtualCount ( $value )

toArray() public méthode

public toArray ( ) : array
Résultat array the list of items in array