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
파일 보기 프로젝트 열기: pradosoft/prado 1 사용 예제들

공개 메소드들

메소드 설명
__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