Filter & sort by field on tables on a table by table bas

A place for users and developers of the Xataface to discuss and receive support.

Filter & sort by field on tables on a table by table bas

Postby tomhousley » Fri Feb 27, 2009 4:33 am

Dear all,

I have a few tables, and i want to have them have a default sort when each table is seen in browse and for some to be filtered

Eg:

tbl_jobs needs to sort by job_id descending
tbl_organisations needs to sort by org_name ascending and filtered where org_showindatabase = 1

Any help would be appreciated.

By the way, Xataface has to be the coolest tool! I have searched and tried to make use of many GPL online database / form builders and without a doubt this is the most powerful coupled with ease of use tool I've used.

Many thanks, Tom
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Postby shannah » Fri Feb 27, 2009 8:35 am

Hi Tom,

Currently there's no configuration parameter for default sort (that would be a nice feature for future). What I generally do when this requirement comes up is to this by php. In the beforeHandleRequest() method of the ApplicationDelegate class:

Code: Select all
function beforeHandleRequest(){
    $app =& Dataface_Application::getInstance();
    $query =& $app->getQuery();
    if ( $query['-table'] == 'tbl_jobs' and !@$query['-sort'] and !$_POST ){
        $query['-sort'] = 'job_id desc';
    }

    ... etc...
}


So you'll notice that I check on a couple of things here:
1. Is the current request for the table.
2. Has the sort been set yet (we don't want to override explicitly set sorts.
3. Is this a POST. Best not to mess with POST requests.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved