See
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910.
Anthony
On Thursday, January 5, 2017 at 11:18:46 PM UTC-5, Pierre Corbeil wrote:
>
> Trying to migrate my old access environment to web2py. I have imported
> all data, can be viewed ok.
> Trying to get a dropdown list (when using smargrid) that is a subset of a
> table.
> been trying for while now, maybe someone can give me a hint.
> Here is the tables :
>
> #
> db.define_table('famille' ,
> Field('famille' ,'string' , label='Famille' , length =
> 25),format='%(famille)s')
> #
> db.define_table('detail' ,
> Field('famille' ,'reference famille'),
> Field('detail' ,'string' , label='Detail' , length =
> 60),format='%(detail)s')
> #
> db.define_table('achat',
> # not showing all the fields to shortens the text a bit
> Field('famille' ,'reference famille' , label='Famille'), #
> shows as a drop down pick list, works ok
> Field('detail' ,'reference detail' , label='Détail' ),
> # show sall the detail, but I would like to view only the ones related to
> the "famille" that has just been selected
> Field('dcc' ,'boolean' , label='Payer ce mois'))
> #
> # The controler, as it is now:
> def manage():
> db.achat.id.readable=False
> db.achat.qui.represent = lambda v, r: '' if v is None else
> (db.qui(v).prenom)
> db.achat.typ.represent = lambda v, r: '' if v is None else
> (db.typ(v).typ)
> db.achat.famille.represent = lambda v, r: '' if v is None else
> (db.famille(v).famille)
> db.achat.detail.represent = lambda v, r: '' if v is None else
> (db.detail(v).detail)
> grid = SQLFORM.smartgrid(db.achat,
> linked_tables=['qui','typ','famille','detail','famdet'],
> fields=[db.achat.quand,
> db.achat.montant,
> db.achat.cash,
> db.achat.qui,
> db.achat.commun,
> db.achat.typ,
> db.achat.note,
> db.achat.famille,
> db.achat.detail,
> db.achat.dcc ],
> orderby=~db.achat.quand,
> create=False,
> exportclasses= dict(csv_with_hidden_cols=False,
> tsv_with_hidden_cols=False, tsv=False, json=False, xml=False, html=False),
> paginate=10)
> return locals()
>
>
>
--
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/d/optout.