When there are numerous tables, it is difficult for the user to see get an information that will help one to enter the right data in the right field. So instead of navigating in the relative tables and lose some time, it is more convenient to add a grafted field from that relative table in the table. To be able to sort a column by the content displayed when this content is extracted form a relative table, a grafted field is necessary because the real content is just an id, not the most convenient to sort in human-readable way.
Two ways to add a grafted filed
The first one is to add a __sql__ statement at the beginning of fields.ini, including the grafted field through a join.
__sql__ = "select p.*, d.total from programmation p left join dev d on p.id_programmation=d.id_programmation"
The second one is to create the function __sql__ in the delegate class
return "select p.*, d.total from programmation p left join dev d on p.id_programmation=d.id_programmation";
Sorting order based on relationship
The solution is to hide the field with the id and to add the grafted field with the name in the fields.ini