The "format" attribute does propagate, so you'll have to write your own
"represent" function for the "room" field (not tested):
Field('room', 'reference room', represent=lambda id, r: '%s %s' % (r.room.
branch.address, r.room.room_no))
The above represent function uses recursive selects, which I think should
work.
Anthony
On Thursday, March 21, 2013 11:30:34 PM UTC-4, 黄祥 wrote:
>
> hi,
>
> did anyone know how to show record representation format that refer to
> another table and that table is refer to another table?
>
> e.g.
> *db.py*
> db.define_table('branch',
> Field('address', 'text'),
> Field('zip'),
> Field('city'),
> Field('country'),
> Field('phone'),
> Field('fax'),
> Field('email'),
> Field('company', 'reference company'),
> format='%(address)s')
>
> db.define_table('room',
> Field('room_no'),
> Field('status', 'list:string'),
> Field('branch', 'reference branch'),
> format='%(branch)s %(room_no)s')
>
> db.define_table('booking',
> Field('scheduled_start', 'datetime'),
> Field('due_date', 'datetime'),
> Field('room', 'reference room'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format='%(scheduled_start)s %(customer)s %(room)s')
>
> *my question is:*
> when i select table booking, i want to see : branch address room no (e.g.
> jakarta 101), notf branch id room no (e.g. 1 101).
>
> many thanks before
>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.