Jump to:

23377 Posts in 18296 Topics by 2868 members

General Questions

SilverStripe Forums » General Questions » DataObject > Casting & GridField Sortable

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

Page: 1
Go to End
Author Topic: 275 Views
  • JoeJoe
    Avatar
    Community Member
    7 Posts

    DataObject > Casting & GridField Sortable Link to this post

    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

    275 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.