Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Controller/Component/DatatablesPaginatorComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Cake\Controller\Component\PaginatorComponent;
use Cake\Datasource\ResultSetInterface;
use Cake\Http\ServerRequest;
use Migrations\ConfigurationTrait;

/**
* DatatablesPaginator component
Expand Down Expand Up @@ -52,12 +53,28 @@ protected function applyOrder(array $data, array $settings): array
continue;
}
$colName = $dtColumns[$colIndex]['data'];
$settings['order'][$colName] = $colOrder;

$settings['order'] = array_merge($settings['order'] ?? [], $this->filterOrder($colName, $colOrder));
}

return $settings;
}

/**
* @param string $colName
* @param string $colOrder
* @return array
*/
protected function filterOrder(string $colName, string $colOrder): array
{
$filters = $this->getConfig('filterOrder') ?? [];
if (isset($filters[$colName])) {
return array_fill_keys($filters[$colName] ?? [], $colOrder);
}

return [$colName => $colOrder];
}

/**
* Translate limit and offset from datatables
*
Expand Down