Twitter Feed

Xataface Maillist

Sign up to receive the Xataface news letter with weekly updates and development tips.

Found 1 of 139 records in table Wiki
Now Showing 1 of 1

Current Record: Grafted_fields

Grafted fields


Grafted Fields


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.*, 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
function __sql__(){
return "select p.*, 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



A couple of things to check for:
  • 1. If you have set blanket default permissions for your fields using the __field__permissions() method you could be disallowing access to the field.
  • 2. If you have set default field visibility in the fields.ini file via the [__global__] section....
  • 3. Check to make sure that your __sql__ directive is at the beginning of the file and that it is __sql__ and not _sql_
  • 4. Try to enter an obviously invalid SQL query for the __sql__ directive to see if you get an error (to confirm that it is picking up the __sql__ directive at all).
blog comments powered by Disqus
Powered by Xataface
(c) 2005-2021 All rights reserved