Thanks Anthony,

The idea is having both view and grid displayed in the same page.
The view is not made by the grid. It have to been displayed if the user 
have clicked on the 'View' button, or not displayed if the user have 
clicked on the "Search" or "Reset" button.

The first time the page is displayed there's only the grid.
When the user click on a view button, the controller see that there's 'view 
in the args', redirect the page to the same page with the record id in vars 
instead of args. Like that the grid is not displayed in the view mode but 
in the table mode.

Controller:
    if 'view' in request.args:
        #I build the vars, one is called product_id, the other keywords
        redirect(URL('my_page', vars=vars))


In the view:
{{if request.vars['product_id'] and session.view == True:}}

The problem is that I have to detect which is the button that have been 
clicked, for setting session.view.
I've tried with Ajax to set a session var but I've got delay problems.

I need to know which is the last clicked button.
Can you help me?

Il giorno martedì 2 maggio 2017 18:45:04 UTC+2, Anthony ha scritto:
>
> You should be able to do this in the controller that handles the grid. 
> Please show the code you tried and explain exactly what happened.
>
> On Monday, May 1, 2017 at 9:49:23 AM UTC-4, Gael Princivalle wrote:
>>
>> Hello.
>>
>> I would like to set a session var when the user click in a SQLFORM.grid 
>> on the search or reset buttons.
>> I've tried with Ajax but the next page is processed before the session 
>> var has been set.
>>
>> Perhaps I can make a modification directly in the web2py files that are 
>> called when the user click on "Search" or "Reset"?
>>
>> Someone knows where they are?
>>
>> Thanks.
>>
>

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

Reply via email to