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.

General Questions /

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

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

DataObject > Casting & GridField Sortable


Reply


375 Views

Avatar
JoeJoe

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.
Thx
Joe