mirror of
https://github.com/UndefinedOffset/SortableGridField.git
synced 2024-10-22 15:05:38 +00:00
Allow 'disableSelection' to be disabled
This commit is contained in:
parent
3e9b1b6e2e
commit
70512329a1
@ -6,13 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator {
|
class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator {
|
||||||
protected $sortColumn;
|
protected $sortColumn;
|
||||||
|
protected $disable_selection=true;
|
||||||
protected $append_to_top=false;
|
protected $append_to_top=false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param String $sortColumn Column that should be used to update the sort information
|
* @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->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');
|
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));
|
return array('header' => $forTemplate->renderWith('GridFieldSortableRows', $args));
|
||||||
}
|
}
|
||||||
@ -120,6 +123,15 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
return $this;
|
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
|
* Detects and corrects items with a sort column value of 0, by appending them to the bottom of the list
|
||||||
* @param GridField $gridField Grid Field Reference
|
* @param GridField $gridField Grid Field Reference
|
||||||
|
@ -60,7 +60,11 @@
|
|||||||
form.removeClass('loading');
|
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() {
|
gridField.find('.datagrid-pagination .ss-gridfield-previouspage, .datagrid-pagination .ss-gridfield-nextpage').each(function() {
|
||||||
$(this).droppable({
|
$(this).droppable({
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="extra sortablerowsheading" colspan="$Colspan">
|
<th class="extra sortablerowsheading" colspan="$Colspan">
|
||||||
<div class="gridfield-sortablerows">
|
<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>
|
<input type="checkbox" id="{$ID}_AllowDragDropCheck" value="1" class="no-change-track<% if $DisableSelection %> gridfield-sortablerows-noselection<% end_if %>"$Checked/>
|
||||||
$SortableToggle
|
<label for="{$ID}_AllowDragDropCheck"><%t GridFieldSortableRows.ALLOW_DRAG_DROP "Allow drag and drop re-ordering" %></label>
|
||||||
$SortOrderSave
|
$SortableToggle
|
||||||
$SortToPage
|
$SortOrderSave
|
||||||
|
$SortToPage
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
Loading…
x
Reference in New Issue
Block a user