Skip to content

Commit

Permalink
API-CHANGE: new GridFieldFooter component
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Seidenberg committed Apr 12, 2012
1 parent e045ffe commit e9dc610
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions css/GridField.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions forms/gridfield/GridFieldFooter.php
@@ -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()))),
);
}
}
5 changes: 5 additions & 0 deletions scss/GridField.scss
Expand Up @@ -471,6 +471,11 @@ $gf_grid_x: 16px;
&.bottom-all {
@include border-bottom-radius($gf_border_radius);
@include background-image(linear-gradient($gf_colour_gradient_light, $gf_colour_gradient_dark));
.datagrid-footer-message {
text-align: center;
padding-top: 6px;
color:$color-text-light;
}
.datagrid-pagination {
padding-top:2px;
position:absolute;
Expand Down
9 changes: 9 additions & 0 deletions templates/Includes/GridFieldFooter.ss
@@ -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>

0 comments on commit e9dc610

Please sign in to comment.