Hook for second sort order
-
- Posts: 6
- Joined: 2013-12-19 20:15
Hook for second sort order
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
In the tablename_init hook (where tablename is the name of the concerned table), add code similar to this:
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).
Code: Select all
$options->DefaultSortField = '2 asc, 4 desc';
$options->DefaultSortDirection = '';

- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
- Need personalized consulting on your specific app and customizations? Book an online call with me here.
-
- Posts: 6
- Joined: 2013-12-19 20:15
Re: Hook for second sort order
Thank you..
Hook now reads:
Only display flights from today's date and order by Date and Time..
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;
}