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 (qiang.xue@gmail.com)
Inheritance: extends TList
Ejemplo n.º 1
0
 /**
  * Switches to the previous page.
  * @return integer|boolean the new page index, false if previous page is not availabe.
  */
 public function previousPage()
 {
     return $this->getIsPreviousPageAvailable() ? parent::previousPage() : false;
 }
Ejemplo n.º 2
0
 public function testToArray()
 {
     $list = new TPagedList(array(1, 2, 3));
     $list->CustomPaging = true;
     self::assertEquals(array(1, 2, 3), $list->toArray());
 }