Prado\Collections\TPagedList::gotoPage PHP Méthode

gotoPage() public méthode

Changes to a page with the specified page index.
public gotoPage ( $pageIndex ) : integer | boolean
Résultat integer | boolean the new page index, false if page index is out of range.
    public function gotoPage($pageIndex)
    {
        if ($pageIndex === $this->_currentPageIndex) {
            return $pageIndex;
        }
        if ($this->_customPaging) {
            if ($pageIndex >= 0 && ($this->_virtualCount < 0 || $pageIndex < $this->getPageCount())) {
                $param = new TPagedListFetchDataEventParameter($pageIndex, $this->_pageSize * $pageIndex, $this->_pageSize);
                $this->onFetchData($param);
                if (($data = $param->getData()) !== null) {
                    $this->setReadOnly(false);
                    $this->copyFrom($data);
                    $this->setReadOnly(true);
                    $oldPage = $this->_currentPageIndex;
                    $this->_currentPageIndex = $pageIndex;
                    $this->onPageIndexChanged(new TPagedListPageChangedEventParameter($oldPage));
                    return $pageIndex;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        } else {
            if ($pageIndex >= 0 && $pageIndex < $this->getPageCount()) {
                $this->_currentPageIndex = $pageIndex;
                $this->onPageIndexChanged(null);
                return $pageIndex;
            } else {
                return false;
            }
        }
    }

Usage Example

Exemple #1
0
 public function testIsLastPage()
 {
     $list = new TPagedList(array(1, 2, 3));
     $list->PageSize = 1;
     $list->gotoPage(0);
     self::assertEquals(false, $list->IsLastPage);
     $list->gotoPage(2);
     self::assertEquals(true, $list->IsLastPage);
 }