Skip to content
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

FIX Respect default sort array in GridFieldOrderableRows #349

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/GridFieldOrderableRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ public function getManipulatedData(GridField $grid, SS_List $list)
if ($list instanceof DataList) {
$classname = $list->dataClass();
if ($defaultSort = Config::inst()->get($classname, 'default_sort')) {
// Check to see if `default_sort` is an array
if (is_array($defaultSort)) {
// If it is, use the first item, as that has highest priority
$defaultSort = array_shift($defaultSort);
}
// Append the default sort to the end of the sort string
// This may result in redundancy... but it seems to work
$sortterm .= ($sortterm ? ', ' : '') . $defaultSort;
Expand Down