With your solution Field('id_01', 'id')now I can add a custom column in the
grid with links (also without a link inside !):
links = [dict(header=T('Brand'), body=lambda row:
(db.brands(row.brand_id_01).name))]
Ok, it works fine, but how can I display this custom column in my custom
single view grid ?
For the description field for example I have:
{{=P(grid.view_form.record.description)}}
For the custom column ?
{{=P(grid.view_form.record.links??)}}
Regards.
Il giorno domenica 8 dicembre 2013 16:44:43 UTC+1, Gael Princivalle ha
scritto:
>
> Hello all.
>
> Well I don't understand really how to manage this problem.
>
> I cannot use web2py id's for referencing my brands, I need to use id's
> from another CRM application called "01". So I have in my "brands" table a
> field called "id_01" and in the "products" table a field called
> "brand_id_01".
> When I modify a "products" row in the admin interface I can choose the
> "brand_id_01" by the "brands.name", OK, but when I display the "products"
> table I see the brand_id_01, KO.
> Also when I display a SQLFORM.grid from the "products" table I don't see
> the "brands.name" instead of the "brand_id_01".
> How I can display the "brands.name" instead of the "brand_id_01" in my
> SQLFORM.grid ?
>
> My db:
> db.define_table('brands',
> Field('id_01', unique = True),
> Field('name'),
> format='%(names')
> db.define_table('products',
> Field('code', unique=True),
> Field('description'),
> Field('brand_id_01', 'reference brands', requires =
> IS_IN_DB(db, db.brands.id_01, '%(name)s')))
>
> My controller:
> def products_listing():
> query=db.products
> fields =
> (db.products.id_01,db.products.code,db.products.description,db.products.brand_id_01)
> grid = SQLFORM.grid(query, fields=fields)
> return dict(grid=grid)
>
> Thanks a lot for any kind of help.
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
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.