Dynamic Query SQLFOR.GRID

64 views
Skip to first unread message

Laurent Lc

unread,
Sep 28, 2015, 10:36:45 AM9/28/15
to web2py-users
function in controller

def showselectionfunding():
    groupe = request.vars['groupe']
    ask_date = request.vars['ask_date']
    query=((db1.test.groupe == groupe)&(db1.test.datefincontrat > ask_date))
    #query=((db1.test.groupe == groupe)&(db1.test.financement== financement)&(db1.test.datefincontrat > ask_date))
    grid = SQLFORM.grid(query=query,user_signature=False, maxtextlength = 40, \
    fields=[db1.test.nom,db1.test.mail,db1.test.datefincontrat],orderby=db1.test.datefincontrat)
    return dict(grid=grid)

imagine now that the var "groupe is a list". the best way to return the result ?
Than you

Massimiliano

unread,
Sep 29, 2015, 5:20:25 AM9/29/15
to web...@googlegroups.com
You can use belongs()

   db1.test.groupe.belongs(groupe) & ...



--
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 web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Massimiliano

Laurent Lc

unread,
Sep 29, 2015, 8:52:55 AM9/29/15
to web...@googlegroups.com

Thank you very much

You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/L7kr59HBrhE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages