def Grid_Home():
    if 'view' in request.args:
        redirect(URL('default', 'displayContents', args=request.args[-1]))
    grid = SQLFORM.grid(db.somedatabase,csv=False,user_signature=False,
                       editable=False, create=False)
   return dict(grid=grid)

The id of the requested record will be in request.args[-1], so that is 
passed on to displayContents in the redirect.

Alternatively, if you want to avoid a redirect, you can instead disable the 
standard View button (by setting details=False), and instead use the 
"links" argument to create your own custom button/link, which could point 
directly to the displayContents URL.

Anthony


On Saturday, June 18, 2016 at 8:47:42 AM UTC-4, Natalie Cluck wrote:
>
> How do I override what the View button does when clicked in SQLFORM.grid? 
> This is what I have:
>
> def Grid_Home():
>     grid = SQLFORM.grid(db.somedatabase,csv=False,user_signature=False,
>                         editable=False, create=False)
>     return dict(grid=grid)
>
> def displayContents():
>     # new page when View button is clicked
>
> I want to create a new grid on the displayContents page that uses my 
> existing databases to display contents of a item listed in the "home 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