BUGFIX: Fix pagination when there are no records

This commit is contained in:
Andrew O'Neil 2012-03-07 14:47:57 +13:00
parent c81bb3b4d3
commit a28485316f

View File

@ -87,7 +87,11 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
$countList = clone $gridField->List; $countList = clone $gridField->List;
$totalRows = $countList->limit(null)->count(); $totalRows = $countList->limit(null)->count();
$totalPages = ceil($totalRows/$this->itemsPerPage); $totalPages = ceil($totalRows/$this->itemsPerPage);
if($totalPages == 0)
$totalPages = 1;
$firstShownRecord = ($this->currentPage - 1) * $this->itemsPerPage + 1; $firstShownRecord = ($this->currentPage - 1) * $this->itemsPerPage + 1;
if($firstShownRecord > $totalRows)
$firstShownRecord = $totalRows;
$lastShownRecord = $this->currentPage * $this->itemsPerPage; $lastShownRecord = $this->currentPage * $this->itemsPerPage;
if($lastShownRecord > $totalRows) if($lastShownRecord > $totalRows)
$lastShownRecord = $totalRows; $lastShownRecord = $totalRows;