Skip to content
Browse files

BUGFIX: Fix pagination when there are no records

  • Loading branch information...
1 parent c81bb3b commit a28485316f7016f89c7671450df0b3446e8ec7f6 @ajoneil ajoneil committed
Showing with 4 additions and 0 deletions.
  1. +4 −0 forms/gridfield/GridFieldPaginator.php
View
4 forms/gridfield/GridFieldPaginator.php
@@ -87,7 +87,11 @@ public function getHTMLFragments($gridField) {
$countList = clone $gridField->List;
$totalRows = $countList->limit(null)->count();
$totalPages = ceil($totalRows/$this->itemsPerPage);
+ if($totalPages == 0)
+ $totalPages = 1;
$firstShownRecord = ($this->currentPage - 1) * $this->itemsPerPage + 1;
+ if($firstShownRecord > $totalRows)
+ $firstShownRecord = $totalRows;
$lastShownRecord = $this->currentPage * $this->itemsPerPage;
if($lastShownRecord > $totalRows)
$lastShownRecord = $totalRows;

0 comments on commit a284853

Please sign in to comment.
Something went wrong with that request. Please try again.