Page 1 of 1
Hook for second sort order
Posted: 2015-12-14 21:38
by mervyngroves
I have an AppGini application that uses a table of flight information. Currently the default sort order is departure date and it only shows flights from "today" . How can I add a hook that will further sort the flight records by departure time, that is ORDER BY date_flight, dep_time?
Re: Hook for second sort order
Posted: 2015-12-15 15:51
by a.gneady
In the tablename_init hook (where tablename is the name of the concerned table), add code similar to this:
Code: Select all
$options->DefaultSortField = '2 asc, 4 desc';
$options->DefaultSortDirection = '';
The above code sorts the table view by the second field ascendingly, then by the fourth field descendingly. The order of fields is according to your AppGini project (which might be different from actual database structure in some cases).
Re: Hook for second sort order
Posted: 2015-12-15 16:04
by mervyngroves
Thank you..
Hook now reads:
Code: Select all
function flights_init(&$options, $memberInfo, &$args){
$date = date('m/d/Y');
addFilter(1, 'and', 3, 'greater-than-or-equal-to' , $date);
$options->DefaultSortField = '3 asc, 8 asc';
$options->DefaultSortDirection = '';
return TRUE;
}
Only display flights from today's date and order by Date and Time..