mirror of
https://github.com/UndefinedOffset/SortableGridField.git
synced 2024-10-22 17:05:38 +02:00
Fixed issue where sortable header and filter could potentially get put back in when changing pages
Fixed issue when sorting cross pages with a many_many list
This commit is contained in:
parent
fb767a6722
commit
786af43ca9
@ -89,10 +89,16 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
||||
* @return DataList Modified Data List
|
||||
*/
|
||||
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
|
||||
$state = $gridField->State->GridFieldSortableHeader;
|
||||
if ($state && !empty($state->SortColumn)) {
|
||||
$headerState = $gridField->State->GridFieldSortableHeader;
|
||||
$state = $gridField->State->GridFieldSortableRows;
|
||||
if ((!is_bool($state->sortableToggle) || $state->sortableToggle==false) && $headerState && !empty($headerState->SortColumn)) {
|
||||
return $dataList;
|
||||
}
|
||||
|
||||
if ($state->sortableToggle == true) {
|
||||
$gridField->getConfig()->removeComponentsByType('GridFieldFilterHeader');
|
||||
$gridField->getConfig()->removeComponentsByType('GridFieldSortableHeader');
|
||||
}
|
||||
|
||||
return $dataList->sort($this->sortColumn);
|
||||
}
|
||||
@ -261,7 +267,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
||||
if ($many_many) {
|
||||
DB::query('UPDATE "' . $table
|
||||
. '" SET "' . $sortColumn.'" = ' . $targetItem->$sortColumn
|
||||
. ' WHERE "' . $componentField . '" = ' . $targetItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
|
||||
. ' WHERE "' . $componentField . '" = ' . $swapItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
|
||||
} else {
|
||||
$swapItem->$sortColumn = $targetItem->$sortColumn;
|
||||
$swapItem->write();
|
||||
|
Loading…
Reference in New Issue
Block a user