mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Fix pagination when there are no records
This commit is contained in:
parent
c81bb3b4d3
commit
a28485316f
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user