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
|
* @return DataList Modified Data List
|
||||||
*/
|
*/
|
||||||
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
|
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
|
||||||
$state = $gridField->State->GridFieldSortableHeader;
|
$headerState = $gridField->State->GridFieldSortableHeader;
|
||||||
if ($state && !empty($state->SortColumn)) {
|
$state = $gridField->State->GridFieldSortableRows;
|
||||||
|
if ((!is_bool($state->sortableToggle) || $state->sortableToggle==false) && $headerState && !empty($headerState->SortColumn)) {
|
||||||
return $dataList;
|
return $dataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($state->sortableToggle == true) {
|
||||||
|
$gridField->getConfig()->removeComponentsByType('GridFieldFilterHeader');
|
||||||
|
$gridField->getConfig()->removeComponentsByType('GridFieldSortableHeader');
|
||||||
|
}
|
||||||
|
|
||||||
return $dataList->sort($this->sortColumn);
|
return $dataList->sort($this->sortColumn);
|
||||||
}
|
}
|
||||||
@ -261,7 +267,7 @@ class GridFieldSortableRows implements GridField_HTMLProvider, GridField_ActionP
|
|||||||
if ($many_many) {
|
if ($many_many) {
|
||||||
DB::query('UPDATE "' . $table
|
DB::query('UPDATE "' . $table
|
||||||
. '" SET "' . $sortColumn.'" = ' . $targetItem->$sortColumn
|
. '" SET "' . $sortColumn.'" = ' . $targetItem->$sortColumn
|
||||||
. ' WHERE "' . $componentField . '" = ' . $targetItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
|
. ' WHERE "' . $componentField . '" = ' . $swapItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
|
||||||
} else {
|
} else {
|
||||||
$swapItem->$sortColumn = $targetItem->$sortColumn;
|
$swapItem->$sortColumn = $targetItem->$sortColumn;
|
||||||
$swapItem->write();
|
$swapItem->write();
|
||||||
|
Loading…
Reference in New Issue
Block a user