Page 1 of 1

Sorting Relationships

PostPosted: Thu Jan 14, 2010 1:51 pm
by mikep
I am trying to sort the records in my relationship tabs. I tried the following statement

SELECT * from Progress_Notes where Client_ID='$Client_ID' ORDER BY Client_ID DESC, Date DESC

but it didn't work. I'm assuming ORDER BY clauses are not supported in Xataface relationships.

How do you go about sorting records in a relationship?

Thank you,
Mike

Re: Sorting Relationships

PostPosted: Thu Jan 14, 2010 2:20 pm
by shannah
Yes. You should not include an order by clause in a relationship definition. Sorting is done at a higher level. E.g. click on the column headings in your relationship tabs. You'll notices that it adds something like -related:sort={column name} to the url.

-Steve

Re: Sorting Relationships

PostPosted: Sat Jan 16, 2010 1:48 am
by mikep
Hi,

I tried adding this to my index.php

if ( !isset($_REQUEST['-sort']) and @$_REQUEST['-relationship']=='Table_Name' ){
$_REQUEST['-sort'] = $_GET['-sort'] = 'Client_ID desc, Date desc';
}

But it didn't seem to work. Where and how can I modify the link for this relationship?

Thanks,
Mike

Re: Sorting Relationships

PostPosted: Sat Jan 16, 2010 9:33 am
by shannah
For relationships, it doesn't use the -sort parameter. It uses the -related:sort parameter.
If you click on a relationship tab and then sort the records by clicking on a column header you'll see what this parameter looks like in the query string.

Re: Sorting Relationships

PostPosted: Sat Jan 16, 2010 9:49 am
by mikep
Ah, thanks. I was only looking at the link for the relationship tab.


Mike