two years later I am struggling with same problem, is grid vars parameter 
now included in web2py?

Dana srijeda, 24. listopada 2012. 11:56:21 UTC+2, korisnik Niphlod napisao 
je:
>
> isn't this a little silly ? we have an args parameter to the grid but not 
> a vars one....
>
> Could you try to test a little mod to the source..... 
>
> - open gluon/sqlhtml.py and scroll until "def grid("
> - add a vars={} default parameter
> - a few line below, there's "def url(**b)"
> - change with this
>     
>     def url(**b):
>             b['args'] = args + b.get('args', [])
>             vars.update(b.get('vars', {}))
>             b['vars'] = vars
>             b['hash_vars'] = False
>             b['user_signature'] = user_signature
>             return URL(**b)
>
>
> Create a grid with
> grid = SQLFORM.grid(table, vars=dict(mycustomvar='mycustomvalue'))
>
> In theory, the 'mycustomvar' parameter should be passed along with 
> navigation into the grid without causing problems.
>
> Disclaimer: use customized vars, not the ones the grid uses (like order, 
> keywords, search,page, etcetc). Should be safe though, in case of collision 
> the grid wins over the vars you passed on instantiation.
>
> On Wednesday, October 24, 2012 8:40:57 AM UTC+2, lyn2py wrote:
>>
>> When/where should I "clean" these variables from session ?
>>> In case user directly accesses second URL (without going thru first URL 
>>> to select the search criteria) they might see incorrect results - since 
>>> controller function will use "old" values 
>>>
>>
>> I suggest to ensure that URLs must be followed. Not possible to clear the 
>> session vars especially if search result has more than one page. Use 
>> user_signature=True for your SQLFORM.grid 
>>
>

-- 
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.

Reply via email to