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 \Prado\Collections\setCustomPaging.
- Managed paging (\Prado\Collections\setCustomPaging=false) : the list is assumed to contain all data and it will manage which page of data are available to user.
- Customized paging (\Prado\Collections\setCustomPaging=true) : the list is assumed to contain only one page of data. An \Prado\Collections\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 \Prado\Collections\setPageSize property specifies the number of items in each page. To access different page of data in the list, set \Prado\Collections\setCurrentPageIndex or call nextPage(), previousPage(), or gotoPage(). The total number of pages can be obtained by \Prado\Collections\getPageCount().
Class hierarchy
- \Prado\Collections\TPagedList
- \Prado\Collections\TList implements IteratorAggregate, ArrayAccess, Countable
- \Prado\TComponent
Since: 3.0
public
|
__construct([null|array<string|int, mixed>|Iterator $data = null ][, bool $readOnly = false ]) : mixed
Constructor.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
itemAt(int $index) : mixed
Returns the item at the specified offset.
This method is exactly the same as offsetGet. |
public
|
|
public
|
offsetExists(int $offset) : bool
Returns whether there is an item at the specified offset.
This method is required by the interface \ArrayAccess. |
public
|
offsetGet(int $offset) : mixed
Returns the item at the specified offset.
This method is required by the interface \ArrayAccess. |
public
|
onFetchData(TPagedListFetchDataEventParameter $param) : mixed
Raises <b>OnFetchData</b> 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 \Prado\Collections\setCustomPaging is true. |
public
|
onPageIndexChanged(TPagedListPageChangedEventParameter $param) : mixed
Raises <b>OnPageIndexChanged</b> event.
This event is raised each time when the list changes to a different page. |
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |