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

DataObject > Casting & GridField Sortable

Go to End



Community Member, 8 Posts

13 February 2013 at 5:29am

Edited: 13/02/2013 5:29am

Hi Guys,

I want to sort my GridField based on a casted value in my DataObject;

In my DataObject, summary_fields i point to a function DownloadsNum;
static $summary_fields = array(
'FirstName' => 'Varchar',
'Surname' => 'Varchar',
'Email' => 'Varchar(256)',
'DownloadsNum' => 'Downloads'

public function DownloadsNum(){
$do = DataObject::get("TrackDownload", "MemberID ='".$this->ID."'");
return $do->count();
This is working, i see the values in my GridField. How can i put this column to a descending order by default?

Hope someone can help.