-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to provide secondary sort column for reports #12128
Conversation
30ee6ea
to
fbb2e65
Compare
core/Plugin/Report.php
Outdated
* ``` | ||
* @return null|callable | ||
*/ | ||
public function getSecondSortColumnCallback() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would rename to getSecondarySortColumnCallback
this looks good to me 👍 We could later also make this available as a global API parameter filter. |
Feedback
|
Added some unit tests |
b889769
to
22a654c
Compare
ca199fd
to
3db458c
Compare
core/DataTable/Filter/Sort.php
Outdated
@@ -90,7 +93,11 @@ public function filter($table) | |||
$config->primaryColumnToSort = $sorter->getPrimaryColumnToSort($table, $this->columnToSort); | |||
$config->primarySortOrder = $sorter->getPrimarySortOrder($this->order); | |||
$config->primarySortFlags = $sorter->getBestSortFlags($table, $config->primaryColumnToSort); | |||
$config->secondaryColumnToSort = $sorter->getSecondaryColumnToSort($row, $config->primaryColumnToSort); | |||
if (!empty($this->secondaryColumnSortCallback)) { | |||
$config->secondaryColumnToSort = call_user_func($this->secondaryColumnSortCallback, $config->primaryColumnToSort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to provide the table as well to the callback function? I'm wondering if it could be useful in some case to make the sort column change based on the contents of the report...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added $table as additional param. might be useful in some cases...
* Allow to provide secondy sort column for reports * rename method * Adds two simple tests to prove secondary column sorting * invoke sort callback with datatable as second parameter
Aims to make it possible to sort reports by a custom secondary column as described in #12127
This is only a prove of concept atm.
If we decide to use it that way I'd go on with adding some tests for it...