Merge pull request #68 from webfox/master

Allow 'disableSelection' to be disabled
This commit is contained in:
Ed Chipman 2015-04-07 09:26:53 -03:00
commit ff7a30825e
3 changed files with 25 additions and 8 deletions

View File

@ -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

View File

@ -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({

View File

@ -1,10 +1,11 @@
<tr>
<th class="extra sortablerowsheading" colspan="$Colspan">
<div class="gridfield-sortablerows">
<input type="checkbox" id="{$ID}_AllowDragDropCheck" value="1" class="no-change-track"$Checked/> <label for="{$ID}_AllowDragDropCheck"><%t GridFieldSortableRows.ALLOW_DRAG_DROP "Allow drag and drop re-ordering" %></label>
$SortableToggle
$SortOrderSave
$SortToPage
<input type="checkbox" id="{$ID}_AllowDragDropCheck" value="1" class="no-change-track<% if $DisableSelection %> gridfield-sortablerows-noselection<% end_if %>"$Checked/>
<label for="{$ID}_AllowDragDropCheck"><%t GridFieldSortableRows.ALLOW_DRAG_DROP "Allow drag and drop re-ordering" %></label>
$SortableToggle
$SortOrderSave
$SortToPage
</div>
</th>
</tr>