diff --git a/src/GridFieldOrderableRows.php b/src/GridFieldOrderableRows.php index b94e085..70c2f66 100755 --- a/src/GridFieldOrderableRows.php +++ b/src/GridFieldOrderableRows.php @@ -8,6 +8,7 @@ use SilverStripe\Control\HTTPResponse_Exception; use SilverStripe\Control\RequestHandler; use SilverStripe\Core\ClassInfo; +use SilverStripe\Core\Config\Config; use SilverStripe\Forms\GridField\GridField; use SilverStripe\Forms\GridField\GridField_ColumnProvider; use SilverStripe\Forms\GridField\GridField_DataManipulator; @@ -360,7 +361,17 @@ public function getManipulatedData(GridField $grid, SS_List $list) $sortterm .= $this->getSortTable($list).'.'.$this->getSortField(); } else { $sortterm .= '"'.$this->getSortTable($list).'"."'.$this->getSortField().'"'; + + if ($list instanceof DataList) { + $classname = $list->dataClass(); + if ($defaultSort = Config::inst()->get($classname, 'default_sort')) { + // Append the default sort to the end of the sort string + // This may result in redundancy... but it seems to work + $sortterm .= ($sortterm ? ', ' : '') . $defaultSort; + } + } } + return $list->sort($sortterm); }