-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API-CHANGE: new GridFieldFooter component
- Loading branch information
Julian Seidenberg
committed
Apr 12, 2012
1 parent
e045ffe
commit e9dc610
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,42 @@ | |||
<?php | |||
/** | |||
* Adding this class to a {@link GridFieldConfig} of a {@link GridField} adds a footer bar to that field. | |||
* The footer looks just like the {@link GridFieldPaginator} control, except without the pagination controls. | |||
* It only display the "Viewing 1-8 of 8" status text and (optionally) a configurable status message. | |||
* | |||
* The purpose of this class is to have a footer that can round off GridField without having to use pagination. | |||
* | |||
* @package sapphire | |||
* @subpackage gridfield | |||
*/ | |||
class GridFieldFooter implements GridField_HTMLProvider { | |||
|
|||
/** | |||
* @var string - a message to display in the footer | |||
*/ | |||
protected $message = null; | |||
|
|||
/** | |||
* | |||
* @param string $message - a message to display in the footer | |||
*/ | |||
public function __construct($message = null) { | |||
if($message) $this->message = $message; | |||
} | |||
|
|||
|
|||
public function getHTMLFragments($gridField) { | |||
$count = $gridField->getList()->count(); | |||
|
|||
$forTemplate = new ArrayData(array( | |||
'Message' => $this->message, | |||
'FirstShownRecord' => 1, | |||
'LastShownRecord' => $count, | |||
'NumRecords' => $count | |||
)); | |||
|
|||
return array( | |||
'footer' => $forTemplate->renderWith('GridFieldFooter', array('Colspan'=>count($gridField->getColumns()))), | |||
); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
<tr> | |||
<td class="bottom-all" colspan="$Colspan"> | |||
<span class="pagination-records-number">$FirstShownRecord - $LastShownRecord of $NumRecords</span> | |||
|
|||
<% if Message %> | |||
<div class="datagrid-footer-message">$Message</div> | |||
<% end_if %> | |||
</td> | |||
</tr> |