From b321b9b99551ff7c412c2d8f3dace356a0a69cff Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 8 Mar 2012 17:51:03 +0100 Subject: [PATCH] MINOR Don't show GridField pagination when no records are found, and ensure the "no results" message is laid out correctly --- forms/gridfield/GridField.php | 2 +- forms/gridfield/GridFieldPaginator.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/forms/gridfield/GridField.php b/forms/gridfield/GridField.php index 11a014b2f..321bd6500 100755 --- a/forms/gridfield/GridField.php +++ b/forms/gridfield/GridField.php @@ -358,7 +358,7 @@ class GridField extends FormField { $row = $this->createTag( 'tr', array("class" => 'ss-gridfield-item ss-gridfield-no-items'), - $this->createTag('td', array(), _t('GridField.NoItemsFound', 'No items found')) + $this->createTag('td', array('colspan' => count($columns)), _t('GridField.NoItemsFound', 'No items found')) ); $content['body'][] = $row; } diff --git a/forms/gridfield/GridFieldPaginator.php b/forms/gridfield/GridFieldPaginator.php index 7150f7da1..7805f227d 100755 --- a/forms/gridfield/GridFieldPaginator.php +++ b/forms/gridfield/GridFieldPaginator.php @@ -87,6 +87,8 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu // Figure out which page and record range we're on $countList = clone $gridField->List; $totalRows = $countList->limit(null)->count(); + if(!$totalRows) return array(); + $totalPages = ceil($totalRows/$this->itemsPerPage); if($totalPages == 0) $totalPages = 1;