PHP Класс 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}.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends TList
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

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

getCount() публичный Метод

public getCount ( ) : integer
Результат integer the number of items in current page

getCurrentPageIndex() публичный Метод

public getCurrentPageIndex ( ) : integer
Результат integer current page index. Defaults to 0.

getCustomPaging() публичный Метод

public getCustomPaging ( ) : boolean
Результат boolean whether to use custom paging. Defaults to false.

getIsFirstPage() публичный Метод

public getIsFirstPage ( ) : boolean
Результат boolean whether the current page is the first page

getIsLastPage() публичный Метод

public getIsLastPage ( ) : boolean
Результат boolean whether the current page is the last page

getIterator() публичный Метод

public getIterator ( ) : Iterator
Результат Iterator iterator

getPageCount() публичный Метод

public getPageCount ( ) : integer
Результат integer number of pages, -1 if under custom paging mode and {@link setVirtualCount VirtualCount} is not set.

getPageSize() публичный Метод

public getPageSize ( ) : integer
Результат integer number of items in each page. Defaults to 10.

getVirtualCount() публичный Метод

public getVirtualCount ( ) : integer
Результат integer user-assigned number of items in data source. Defaults to 0.

gotoPage() публичный Метод

Changes to a page with the specified page index.
public gotoPage ( $pageIndex ) : integer | boolean
Результат integer | boolean the new page index, false if page index is out of range.

indexOf() публичный Метод

public indexOf ( $item ) : integer
Результат integer the index of the item in the list (0 based), -1 if not found.

itemAt() публичный Метод

This method is exactly the same as {@link offsetGet}.
public itemAt ( $index ) : mixed
Результат mixed the item at the index

nextPage() публичный Метод

Switches to the next page.
public nextPage ( ) : integer | boolean
Результат integer | boolean the new page index, false if next page is not available.

offsetExists() публичный Метод

This method is required by the interface \ArrayAccess.
public offsetExists ( $offset ) : boolean
Результат boolean

offsetGet() публичный Метод

This method is required by the interface \ArrayAccess.
public offsetGet ( $offset ) : mixed
Результат mixed the item at the offset

onFetchData() публичный Метод

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() публичный Метод

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

previousPage() публичный Метод

Switches to the previous page.
public previousPage ( ) : integer | boolean
Результат integer | boolean the new page index, false if previous page is not available.

setCurrentPageIndex() публичный Метод

public setCurrentPageIndex ( $value )

setCustomPaging() публичный Метод

public setCustomPaging ( $value )

setPageSize() публичный Метод

public setPageSize ( $value )

setVirtualCount() публичный Метод

public setVirtualCount ( $value )

toArray() публичный Метод

public toArray ( ) : array
Результат array the list of items in array