Permalink
Browse files

API-CHANGE: new GridFieldFooter component

  • Loading branch information...
Julian Seidenberg
Julian Seidenberg committed Apr 12, 2012
1 parent e045ffe commit e9dc6104488c25807b12d27352e399a44af7ef3f
Showing with 57 additions and 0 deletions.
  1. +1 −0 css/GridField.css
  2. +42 −0 forms/gridfield/GridFieldFooter.php
  3. +5 −0 scss/GridField.scss
  4. +9 −0 templates/Includes/GridFieldFooter.ss
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -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()))),
+ );
+ }
+}
View
@@ -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;
@@ -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.