Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Custom sort of DataObjects

Go to End

3 Posts   1193 Views


Community Member, 107 Posts

8 August 2012 at 9:26pm

Hey there!

How can I custom sort DataObjects - means how to sort them independent from it's columns. This was possible with the DataObject Manager Module in SS 2.x and it was great! :-)

Thanks. Mario

Matty Balaam

Community Member, 74 Posts

9 August 2012 at 3:53am

I think it's going to be introduced to the core at a later date, but at the moment you need to install this module:


Community Member, 107 Posts

9 August 2012 at 4:42am

Edited: 10/08/2012 7:43pm

That module works great .. It took me sometime to get it working so here few things that may save you alot of time :
Example for a basic Gallery module = Gallery has_many GalleryImages
** GalleryImage.php
- Make sure you add field for SortID
Code to use :
// to change the default sorting to the new SortID
public static $default_sort = 'SortID Asc';
// To change the Default Value if SortID to LastSortID+1 , basic auto sort
function onBeforeWrite() {
if (!$this->SortID) {
return $this->SortID = $this->getNextSortID();

public function getNextSortID() {
return $this->SGallery()->Images()->Last()->SortID + 1;

** Gallery.php
function getCMSFields() {
$fields = parent::getCMSFields();
$gridFieldConfig = GridFieldConfig_RelationEditor::create();
new GridFieldSortableRows("SortID")