NEW: Make the record count in GridFieldFooter optional

This commit is contained in:
Jeremy Shipman 2014-11-13 13:48:02 +13:00
parent b15b93630c
commit d7eb2757fe
2 changed files with 12 additions and 8 deletions

View File

@ -21,15 +21,17 @@ class GridFieldFooter implements GridField_HTMLProvider {
* @var string - a message to display in the footer * @var string - a message to display in the footer
*/ */
protected $message = null; protected $message = null;
protected $showrecordcount;
/** /**
* *
* @param string $message - a message to display in the footer * @param string $message - a message to display in the footer
*/ */
public function __construct($message = null) { public function __construct($message = null, $showrecordcount = true) {
if($message) { if($message) {
$this->message = $message; $this->message = $message;
} }
$this->showrecordcount = $showrecordcount;
} }
@ -37,6 +39,7 @@ class GridFieldFooter implements GridField_HTMLProvider {
$count = $gridField->getList()->count(); $count = $gridField->getList()->count();
$forTemplate = new ArrayData(array( $forTemplate = new ArrayData(array(
'ShowRecordCount' => $this->showrecordcount,
'Message' => $this->message, 'Message' => $this->message,
'FirstShownRecord' => 1, 'FirstShownRecord' => 1,
'LastShownRecord' => $count, 'LastShownRecord' => $count,

View File

@ -1,12 +1,13 @@
<tr> <tr>
<td class="bottom-all" colspan="$Colspan"> <td class="bottom-all" colspan="$Colspan">
<span class="pagination-records-number"> <% if $ShowRecordCount %>
$FirstShownRecord - <span class="pagination-records-number">
$LastShownRecord $FirstShownRecord -
<% _t('TableListField_PageControls_ss.OF', 'of', 'Example: View 1 of 2') %> $LastShownRecord
$NumRecords <% _t('TableListField_PageControls_ss.OF', 'of', 'Example: View 1 of 2') %>
</span> $NumRecords
</span>
<% end_if %>
<% if $Message %> <% if $Message %>
<div class="datagrid-footer-message">$Message</div> <div class="datagrid-footer-message">$Message</div>
<% end_if %> <% end_if %>