diff --git a/code/forms/GridFieldSortableRows.php b/code/forms/GridFieldSortableRows.php index caab808..579ca7f 100644 --- a/code/forms/GridFieldSortableRows.php +++ b/code/forms/GridFieldSortableRows.php @@ -6,13 +6,16 @@ */ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator { protected $sortColumn; + protected $disable_selection=true; protected $append_to_top=false; - + /** * @param String $sortColumn Column that should be used to update the sort information + * @param bool $disableSelection */ - public function __construct($sortColumn) { + public function __construct($sortColumn, $disableSelection = true) { $this->sortColumn = $sortColumn; + $this->disable_selection = $disableSelection; } /** @@ -80,7 +83,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP Requirements::javascript(SORTABLE_GRIDFIELD_BASE . '/javascript/GridFieldSortableRows.js'); - $args = array('Colspan' => count($gridField->getColumns()), 'ID' => $gridField->ID()); + $args = array('Colspan' => count($gridField->getColumns()), 'ID' => $gridField->ID(), 'DisableSelection' => $this->disable_selection); return array('header' => $forTemplate->renderWith('GridFieldSortableRows', $args)); } @@ -119,6 +122,15 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP $this->append_to_top=$value; return $this; } + + /** + * @param bool $value Boolean true to disable selection of table contents false to enable selection + * @return GridFieldSortableRows Returns the current instance + */ + public function setDisableSelection($value){ + $this->disable_selection = $value; + return $this; + } /** * Detects and corrects items with a sort column value of 0, by appending them to the bottom of the list diff --git a/javascript/GridFieldSortableRows.js b/javascript/GridFieldSortableRows.js index b82b24f..27c23a8 100644 --- a/javascript/GridFieldSortableRows.js +++ b/javascript/GridFieldSortableRows.js @@ -60,7 +60,11 @@ form.removeClass('loading'); }); } - }).disableSelection(); + }); + + if(refCheckbox.hasClass('gridfield-sortablerows-noselection')){ + gridField.find('tbody').disableSelection(); + } gridField.find('.datagrid-pagination .ss-gridfield-previouspage, .datagrid-pagination .ss-gridfield-nextpage').each(function() { $(this).droppable({ diff --git a/templates/Includes/GridFieldSortableRows.ss b/templates/Includes/GridFieldSortableRows.ss index d97a70d..ad9ad9e 100644 --- a/templates/Includes/GridFieldSortableRows.ss +++ b/templates/Includes/GridFieldSortableRows.ss @@ -1,10 +1,11 @@