sorting order based on relationship

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

sorting order based on relationship

Postby Jean » Wed Sep 21, 2011 4:57 am

Hi Steve,

I have a relationship between 2 tables
Code: Select all
lieu : id_lieu, nom
programmation: id_programmation, id_lieu...

On my programmation list view, if I click on the id_lieu header, my items are sorted by id_lieu and not lieu.nom.
The relationships.ini is well set up...
My url is
Code: Select all
-table=programmation&-sort=id_lieu

How can I sort by lieu.nom instead of programmation.id_lieu ?

Thank you

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France

Re: sorting order based on relationship

Postby shannah » Wed Sep 21, 2011 9:36 am

Create a grafted field on your programmation table for this. Then hide the id_lieu in list view and show nom instead.
e.g.
Code: Select all
__sql__ = "select p.*, l.nom as lieu_nom from programmation p left join lieu l on p.id_lieu=l.id_lieu"

[lieu_nom]
order=10

[id_lieu]
visibility:list=hidden



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

Re: sorting order based on relationship

Postby Jean » Wed Sep 21, 2011 10:01 am

thank you Steve for your explanation, I'll add it in the wiki.

Jean
Jean
 
Posts: 259
Joined: Wed Nov 07, 2007 1:30 am
Location: Pau, France


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 22 guests

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