I have an admin model tab (called "Appointments") for a SilverStripe that stored form submissions. Everything is working fine and the data is displaying inside the summary grid. However, I need to find a way to change the default sorting of the data. Right now, entries are listed oldest to newest but I need to make it so the newest is always first.
Looking at the mysql table, I see there is a Created column and LastEdited column by default. I'd like to somehow make use of the Created column so I can set a custom sort to override what the default is, but I am not sure how to do this. I've never tried to override the default sorting method for an admin model's sumimmary grid.
Here is the code for the Appointment class::
<?php
class Appointment extends DataObject {
private static $db = array(
'Name' => 'varchar',
'Email' => 'varchar',
'Phone' => 'varchar',
'Message' => 'HTMLText',
);
private static $summary_fields = array(
'Name',
'Email',
'Phone',
'Message',
);
private static $field_labels = array(
'Name' => 'Name',
'Email' => 'Email',
'Phone' => 'Phone',
'Message' => 'Message',
);
}