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}.