Skip to content

Commit

Permalink
invoke sort callback with datatable as second parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jun 13, 2018
1 parent 5d5597e commit 0a41b7b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/DataTable/Filter/Sort.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Sort extends BaseFilter
* @param bool|callback $doSortBySecondaryColumn If true will sort by a secondary column. The column is automatically
* detected and will be either nb_visits or label, if possible.
* If callback given it will sort by the column returned by the callback (if any)
* callback will be called with 2 parameters: primaryColumnToSort and table
*/
public function __construct($table, $columnToSort, $order = 'desc', $naturalSort = true, $recursiveSort = true, $doSortBySecondaryColumn = false)
{
Expand Down Expand Up @@ -94,7 +95,7 @@ public function filter($table)
$config->primarySortOrder = $sorter->getPrimarySortOrder($this->order);
$config->primarySortFlags = $sorter->getBestSortFlags($table, $config->primaryColumnToSort);
if (!empty($this->secondaryColumnSortCallback)) {
$config->secondaryColumnToSort = call_user_func($this->secondaryColumnSortCallback, $config->primaryColumnToSort);
$config->secondaryColumnToSort = call_user_func($this->secondaryColumnSortCallback, $config->primaryColumnToSort, $table);
} else {
$config->secondaryColumnToSort = $sorter->getSecondaryColumnToSort($row, $config->primaryColumnToSort);
}
Expand Down

0 comments on commit 0a41b7b

Please sign in to comment.