On 19/10/2011 13:49, brushek wrote:
Hello,

I want to use SQLFORM.grid in one controller like this:

def klienci():
     if request.vars.a == 'adresacje':
         grid=SQLFORM.grid(db.adresacje,user_signature=False)
     elif request.vars.a == 'serwery' or 'serwery' in request.args:
         grid=SQLFORM.grid(db.serwery,user_signature=False)
     elif request.vars.a == 'klienci':
         grid=SQLFORM.grid(db.klienci,user_signature=False)
     return dict(grid=grid)

the problem is that the controller is reloaded when you click on grid command as edit or new page but the variable "a" is no more posted to the page... why not to use different controllers?? it's surely the easiest way

    Manuele

Form is showing, but when I click on edit (or enything else action) I
get following error:

Traceback (most recent call last):
   File "/home/users/brushek/web2py/gluon/restricted.py", line 192, in
restricted
     exec ccode in environment
   File "/home/users/brushek/web2py/applications/staty/controllers/
default.py", line 135, in<module>
   File "/home/users/brushek/web2py/gluon/globals.py", line 149, in
<lambda>
     self._caller = lambda f: f()
   File "/home/users/brushek/web2py/applications/staty/controllers/
default.py", line 92, in klienci
     return dict(grid=grid)
UnboundLocalError: local variable 'grid' referenced before assignment


How to use grid with vars ? Do I need to make diffrent controllers/
views to use grid ?

regards
brushek

Reply via email to