Skip to content
This repository
Browse code

API-CHANGE: new GridFieldFooter component

  • Loading branch information...
commit e9dc6104488c25807b12d27352e399a44af7ef3f 1 parent e045ffe
Julian Seidenberg authored April 12, 2012
1  css/GridField.css
@@ -76,6 +76,7 @@
76 76
 .cms table.ss-gridfield-table tr th span.non-sortable { padding: 1em 1em; display: block; }
77 77
 .cms table.ss-gridfield-table tr td { border-right: 1px solid rgba(0, 0, 0, 0.1); padding: 6.4px 12px; color: #666666; }
78 78
 .cms table.ss-gridfield-table tr td.bottom-all { -moz-border-radius-bottomleft: 7px; -webkit-border-bottom-left-radius: 7px; -o-border-bottom-left-radius: 7px; -ms-border-bottom-left-radius: 7px; -khtml-border-bottom-left-radius: 7px; border-bottom-left-radius: 7px; -moz-border-radius-bottomright: 7px; -webkit-border-bottom-right-radius: 7px; -o-border-bottom-right-radius: 7px; -ms-border-bottom-right-radius: 7px; -khtml-border-bottom-right-radius: 7px; border-bottom-right-radius: 7px; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #b1c0c5), color-stop(100%, #7f9198)); background-image: -webkit-linear-gradient(#b1c0c5, #7f9198); background-image: -moz-linear-gradient(#b1c0c5, #7f9198); background-image: -o-linear-gradient(#b1c0c5, #7f9198); background-image: -ms-linear-gradient(#b1c0c5, #7f9198); background-image: linear-gradient(#b1c0c5, #7f9198); }
  79
+.cms table.ss-gridfield-table tr td.bottom-all .datagrid-footer-message { text-align: center; padding-top: 6px; color: white; }
79 80
 .cms table.ss-gridfield-table tr td.bottom-all .datagrid-pagination { padding-top: 2px; position: absolute; left: 50%; margin-left: -116px; }
80 81
 .cms table.ss-gridfield-table tr td.bottom-all .datagrid-pagination .pagination-page-number { color: white; }
81 82
 .cms table.ss-gridfield-table tr td.bottom-all .datagrid-pagination .pagination-page-number input { width: 35px; height: 18px; margin-bottom: -6px; padding: 0px; }
42  forms/gridfield/GridFieldFooter.php
... ...
@@ -0,0 +1,42 @@
  1
+<?php
  2
+/**
  3
+ * Adding this class to a {@link GridFieldConfig} of a {@link GridField} adds a footer bar to that field.
  4
+ * The footer looks just like the {@link GridFieldPaginator} control, except without the pagination controls.
  5
+ * It only display the "Viewing 1-8 of 8" status text and (optionally) a configurable status message.
  6
+ *
  7
+ * The purpose of this class is to have a footer that can round off GridField without having to use pagination.
  8
+ *
  9
+ * @package sapphire
  10
+ * @subpackage gridfield
  11
+ */
  12
+class GridFieldFooter implements GridField_HTMLProvider {
  13
+
  14
+	/**
  15
+	 * @var string - a message to display in the footer
  16
+	 */
  17
+	protected $message = null;
  18
+
  19
+	/**
  20
+	 *
  21
+	 * @param string $message - a message to display in the footer
  22
+	 */
  23
+	public function __construct($message = null) {
  24
+		if($message) $this->message = $message;
  25
+	}
  26
+
  27
+
  28
+	public function getHTMLFragments($gridField) {
  29
+		$count = $gridField->getList()->count();
  30
+
  31
+		$forTemplate = new ArrayData(array(
  32
+			'Message' => $this->message,
  33
+			'FirstShownRecord' => 1,
  34
+			'LastShownRecord' => $count,
  35
+			'NumRecords' => $count
  36
+		));
  37
+
  38
+		return array(
  39
+			'footer' => $forTemplate->renderWith('GridFieldFooter', array('Colspan'=>count($gridField->getColumns()))),
  40
+		);
  41
+	}
  42
+}
5  scss/GridField.scss
@@ -471,6 +471,11 @@ $gf_grid_x:	16px;
471 471
 				&.bottom-all {
472 472
 					@include border-bottom-radius($gf_border_radius);
473 473
 					@include background-image(linear-gradient($gf_colour_gradient_light, $gf_colour_gradient_dark));
  474
+					.datagrid-footer-message {
  475
+					    text-align: center;
  476
+						padding-top: 6px;
  477
+				        color:$color-text-light;
  478
+					}
474 479
 					.datagrid-pagination {
475 480
 						padding-top:2px;
476 481
 						position:absolute;
9  templates/Includes/GridFieldFooter.ss
... ...
@@ -0,0 +1,9 @@
  1
+<tr>
  2
+	<td class="bottom-all" colspan="$Colspan">
  3
+		<span class="pagination-records-number">$FirstShownRecord - $LastShownRecord of $NumRecords</span>
  4
+
  5
+		<% if Message %>
  6
+		<div class="datagrid-footer-message">$Message</div>
  7
+		<% end_if %>
  8
+	</td>
  9
+</tr>

0 notes on commit e9dc610

Please sign in to comment.
Something went wrong with that request. Please try again.