Why the redirection?

grid accepts a "search_widget" parm where you can create your own widget. 
 Why not figure out how to use that?

Admittedly the manual doesn't help much, but you have the source code in 
gluon/sqlhtml.py.

On Tuesday, October 23, 2012 7:48:11 AM UTC-4, Mandar Vaze wrote:
>
> Hi,
>
> I recently added a new SQLFORM.grid which is created based on parameters 
> selected in previous controller function. 
> The query used is based on the request.vars passed from previous 
> controller. I can see the grid alright.
> (Something like this 
> http://www.mail-archive.com/web2py@googlegroups.com/msg30769.html Except 
> instead of SQLTABLE I am using SQLFORM.grid)
>
> Problem : 
> The "extended" functionality of SQLFORM.grid doesn't seem to work like 
> "View", "Search", and Pagination etc. Since they call the same controller 
> (but there are no request.vars this time)
>
> I was able to workaround for "view" where I check if request.args(0) 
> =='view', and then redirect to another controller, where record ID is 
> available as request.args(2)
> But I don't know what to do for Search and Pagination.
>
> I think there is a better way, and I wouldn't have to "workaround" for 
> "view" either.
>
> Here is pseudo-code just to give better idea :
>
> def chooseView():
>      # Form with two drop downs where user chooses parameters for the 
> report
>      # Similar to index function from the URL provided below
>      if form.accepts(request.vars, session):                             
>         
>          redirect(URL(r=request, f='viewReport', vars=request.vars))
>
>
> def viewReport():
>      # Following is hack, wanna get rid of if possible
>      if request.args(0) in ['view']:                                     
>         
>           redirect(URL('default', 'viewRecordDetails', args=request.args,vars
> =request.vars)) 
>      # Checks like filter1, filter2 exists in request.vars
>      filter1 = requesr.vars.filter1
>      filter2 = requesr.vars.filter2
>
>
>      reportQry = db((db.table.field1 == filter1) & (db.table.field2 ==filter2
> ))
>      grid = SQLFORM.grid(reportQry.query, create=False, editable=False,csv
> =False, deletable=False, searchable=True)
>      return dict(grid=grid)
>
>
> Problem now if when I click on search, viewReport is called with 
> request.vars as follows :
> <Storage {'keywords': 'Text I searched'}>
>
> When I click on View button in the grid, viewReport is called with 
> request.args as follows :
> ['view', 'table', '83']
> I was able workaround this as explained above.
>
> I did not capture data when clicked on one of the numbers in the 
> pagination bar. But I guess viewReport is called with some request params.
>
> Please suggest what is the correct way to handle so that "built-in" 
> functionality like view, search, pagination etc work.
>
> (On web2py 2.0.9 and 2.0.8 - both have problem - in case it matters)
>
> Thanks in anticipation
>
> -Mandar
>
>
>
>
>
>
>

-- 



Reply via email to