Permalink
Browse files

ENHANCEMENT Release of DataGridPagination

This class extends the DataGridPresenter with the behaviour and looks of a paginated Datagrid.
  • Loading branch information...
1 parent cf408d7 commit 83e90aaafed72e2d59b3dbf9b5a26a4dca3348c2 @stojg stojg committed Oct 27, 2011
@@ -0,0 +1,3 @@
+.ss-gridfield-pagination { text-align: center; padding-bottom: 10px; }
+
+.ss-gridfield-pagination-button.loading { background: url(../images/network-save.gif) no-repeat 0% 50%; padding-left: 20px; }
View
@@ -1,7 +1,25 @@
<?php
/**
* Displays a {@link SS_List} in a grid format.
- *
+ *
+ * GridFIeld is a field that takes an SS_List and displays it in an table with rows
+ * and columns. It reminds of the old TableFields but works with SS_List types
+ * and only loads the necessary rows from the list.
+ *
+ * The minimum configuration is to pass in name and title of the field and a
+ * SS_List.
+ *
+ * <code>
+ * $gridField = new GridField('ExampleGrid', 'Example grid', new DataList('Page'));
+ * </code>
+ *
+ * If you want to modify the output of the grid you can attach a customised
+ * DataGridPresenter that are the actual Renderer of the data. Sapphire provides
+ * a default one if you chooses not to.
+ *
+ * @see GridFieldPresenter
+ * @see SS_List
+ *
* @package sapphire
* @subpackage forms
*/
@@ -10,7 +28,7 @@ class GridField extends FormField {
/**
* @var SS_List
*/
- protected $dataSource = null;
+ protected $list = null;
/**
* @var string
@@ -26,27 +44,44 @@ class GridField extends FormField {
* @var string - the classname of the DataObject that the GridField will display
*/
protected $modelClassName = '';
-
+
+ /**
+ * Url handlers
+ *
+ * @var array
+ */
+ public static $url_handlers = array(
+ '$Action' => '$Action',
+ );
+
/**
* Creates a new GridField field
*
* @param string $name
* @param string $title
- * @param SS_List $datasource
+ * @param SS_List $dataList
* @param Form $form
- * @param string $dataPresenterClassName
+ * @param string|GridFieldPresenter $dataPresenterClassName - can either pass in a string or an instance of a GridFieldPresenter
*/
- public function __construct($name, $title = null, SS_List $datasource = null, Form $form = null, $dataPresenterClassName = 'GridFieldPresenter') {
+ public function __construct($name, $title = null, SS_List $dataList = null, Form $form = null, $dataPresenterClassName = 'GridFieldPresenter') {
parent::__construct($name, $title, null, $form);
- if ($datasource) {
- $this->setDatasource($datasource);
+ if ($dataList) {
+ $this->setList($dataList);
}
$this->setPresenter($dataPresenterClassName);
}
/**
+ *
+ * @return string - HTML
+ */
+ public function index() {
+ return $this->FieldHolder();
+ }
+
+ /**
* @param string $modelClassName
*/
public function setModelClass($modelClassName) {
@@ -63,8 +98,8 @@ public function getModelClass() {
if ($this->modelClassName) {
return $this->modelClassName;
}
- if ($this->datasource->dataClass) {
- return $this->datasource->dataClass;
+ if ($this->list->dataClass) {
+ return $this->list->dataClass;
}
throw new Exception(get_class($this).' does not have a modelClassName');
@@ -113,11 +148,10 @@ public function getPresenter(){
/**
* Set the datasource
*
- * @param SS_List $datasource
+ * @param SS_List $list
*/
- public function setDataSource(SS_List $datasource) {
- $this->datasource = $datasource;
-
+ public function setList(SS_List $list) {
+ $this->list = $list;
return $this;
}
@@ -126,8 +160,8 @@ public function setDataSource(SS_List $datasource) {
*
* @return SS_List
*/
- public function getDataSource() {
- return $this->datasource;
+ public function getList() {
+ return $this->list;
}
/**
Oops, something went wrong.

0 comments on commit 83e90aa

Please sign in to comment.