Merge pull request #95 from SilbinaryWolf/master

Fix bug where the current sort value is pulled from the base table if…
This commit is contained in:
Marcus 2015-07-31 12:14:19 +10:00
commit 0e3b6318e6

View File

@ -238,7 +238,25 @@ class GridFieldOrderableRows extends RequestHandler implements
$this->populateSortValues($items);
// Generate the current sort values.
if ($items instanceof ManyManyList)
{
$current = array();
foreach ($items->toArray() as $record)
{
// NOTE: _SortColumn0 is the first ->sort() field
// used by SS when functions are detected in a SELECT
// or CASE WHEN.
if (isset($record->_SortColumn0)) {
$current[$record->ID] = $record->_SortColumn0;
} else {
$current[$record->ID] = $record->$field;
}
}
}
else
{
$current = $items->map('ID', $field)->toArray();
}
// Perform the actual re-ordering.
$this->reorderItems($list, $current, $ids);