[web2py] retrieve records and create SQLFORM?

2014-04-29 Thread LoveWeb2py
Hello, I'm trying to create a search function that allows users to search the database without accessing the SQLFORM. Is there a good way to display multiple results based on the record id? Could I create a unique SQLFORM view just on the record IDs that are retrieved? Basically my search

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread Richard Vézina
Sure! Custom : You create a form (with SQLFORM) to get what the user want to know that gonna be the parameters of your search... Then you make a query (db(db.table.field_in_which_you_search == the_parameters_you_get_by_your_form).select(db.table.ALL), you create a grid with the results of the

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread LoveWeb2py
Thank you, Richard! This is great. How could I pass the parameters from a list though? I'm still learning the DAL. So if I have 6 records I want to return with the id in the list [1,2,5,7,204] How could I do that? Any code example would help. On Tuesday, April 29, 2014 9:58:03 AM UTC-4,

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread Richard Vézina
This should return a list of ids : [row.id for row in db(SQL WHERE CLAUSE).select(db.table.id)] Richard On Tue, Apr 29, 2014 at 10:02 AM, LoveWeb2py atayloru...@gmail.com wrote: Thank you, Richard! This is great. How could I pass the parameters from a list though? I'm still learning the

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread LoveWeb2py
Okay i'll give that a try. So I'll iterate through my list first and then use that clause? For id in records: [row.id for row in db(db.search_queries == id).select(db.table.id)] ?? Put something like that into the controller as SQLFORM and it will return those records? This is so

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread Richard Vézina
You can... Though you iterate twice for notting... SQLFORM is an API for creating self submitting form. What you probably want if you display many records is a grid or a table (html table finally). SQLFORM.grid() have been created for that. It's more difficult to start using it than crud.select()

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread LoveWeb2py
Richard, I have read the book and tried most of the examples and use SQLFORM.smartgrid() on many of my tables. The challenge I am having is I only want select records to be returned based on a users search and I guess I didn't understand the syntax well enough. I'll play around with it. Thank

Re: [web2py] retrieve records and create SQLFORM?

2014-04-29 Thread Richard Vézina
SQLFORM.grid is enough. What you want just the ID of the record (no meaning so I guess you want display all the records data). In this case : rows = db(query).select(db.table.ALL) for row in rows: row.any_field # You can access to the data of your records # You can