Actually, this is a better way to generate the complete search form (you 
may need to fiddle with the CSS):

search_form = SQLFORM.grid(db.members, searchable=True).element(
'.web2py_console')[1]

That extracts just the search form from within the .web2py_console part of 
the grid DOM. When you submit the form, the query will be available in 
request.var.keywords, which you can then pass to the SQLFORM.build_query() 
method to generate the DAL Query.

Anthony

On Sunday, March 31, 2013 11:52:56 AM UTC-4, Jake Lowen wrote:
>
> I appreciate the answer, but I can't figure out the syntax and can't find 
> documentation.
>
> For example, I can't generate the search_menu via:
>
> db.define_table('members',
> Field('first_name','string'),
> Field('last_name','string'),
> Field('address_street_1','string', label="Address 1"),
> Field('address_street_2','string', label="Address 2"),
> Field('address_city','string', label="City"),
> Field('address_state','string', label="State", requires=IS_IN_SET(states)),
> Field('address_zip','string', label="Zip"),
> Field('address_zip4','string', label="+4"),
> Field('phone_home','string'),
> Field('phone_mobile','string'),
> Field('phone_work','string'),
> Field('email','string'),
> Field('union_international','string', 
> label="Int'l",requires=IS_IN_SET(internationals)),
> Field('union_local','string',label="local"),
> Field('district_ks_house','string',writable=False),
> Field('district_ks_senate','string',writable=False),
> )
>
> def search_test():
>        search = SQLFORM.search_ment([db.members.district_ks_house, 
> db.members.district_ks_senate])
>        return locals()
>
>
> On Sunday, March 31, 2013 10:26:11 AM UTC-5, Anthony wrote:
>>
>> You can use SQLFORM.search_menu([list of fields]) to build the search 
>> menu, and once the search is submitted, you can use SQLFORM.build_set([list 
>> of fields], keywords=request.vars.keywords) to get the DAL Set object 
>> associated with the search.
>>
>> Anthony
>>
>> On Saturday, March 30, 2013 7:05:17 PM UTC-4, Jake Lowen wrote:
>>>
>>> I like the way that SQLFORM.grid search works. Once I've searched for 
>>> records and come up with the set I want, How can I pass that set off to 
>>> another function to do work just on those filtered records?   Or in other 
>>> words.. if I have 100 records, and I use the grid search to narrow it down 
>>> to 15... how can I pass just those 15 records to another controller 
>>> function?
>>>
>>> Is it possible to get at the matching records in the grid as is or do I 
>>> need to build another search tool?
>>>
>>> Thanks!
>>>
>>

-- 

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


Reply via email to