You can do something like:

results = results.sort(lambda row: row.first_name)


On Sunday, 12 January 2014 22:21:03 UTC-6, Sarbjit wrote:
>
> As per suggestions from this 
> post.<https://groups.google.com/forum/#!searchin/web2py/passing$20query$20controller/web2py/meeqqMTozrQ/o_kIUeKDkZ4J>I
>  have solved the problem to view the grid results in a different 
> controller by storing the grid results in a session and in the second 
> controller, I am retrieving the results from session and displaying them.
>
> *PROBLEM :-*
>
> With this implantation, I am having problem using sort method on grid 
> results header. On using sort, I get the following URL :
>
> /test/default/search?keywords=&order=testdb.testname&_signature=.....
>
> @auth.requires_login()  
> def search():
>     form,results = dynamic_search(db.testdb)
>     if form.process().accepted:
>         session.results = results
>         redirect(URL('results'))
>     return dict(form=form,results=results)
>
> @auth.requires_login()         
> def results():
>     results = session.results
>     return dict(results=results)
>
> So my controller, starts showing all the records and search query results 
> are lost.
>
> Is there a way I can sort the grid results stored in the session. So, I am 
> planning to parse the URL and based on the order specified in the URL, I 
> can sort the results.
>
> Other solution could be to use "orderby" while retrieving the results from 
> GRID. But I feel that if I recompute the results from GRID, my selection in 
> the dynamic form (used to build query) would be lost and it will again end 
> up showing all the results.
>
> Please let me know what is the efficient way to handle this?
>
>
>

-- 
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/groups/opt_out.

Reply via email to