On Monday, April 29, 2019 at 6:22:26 PM UTC-4, jcrma...@gmail.com wrote:
>
> Grid search collects all records from all fields on each request. Isn't 
> this bad for performance?
>

Are you referring to "reference" fields, which result in a select element 
showing associated values from the foreign table? If so, that is the result 
of the default IS_IN_DB validator given to such fields, which results in a 
select element being created when the field appears in forms as well as the 
search menu. You can override this behavior by putting the validator in a 
list:

db.mytable.myreferencefield.requires = [db.mytable.myreferencefield]

However, in that case, forms and the search menu will simply present a 
numeric input field, and you would need to search by the record ID, so 
probably not very useful. Alternatively, you can specify an autocomplete 
widget, but that won't help in the grid search menu.
 

> Isn't it possible to change this behavior to only load the records when 
> the user selects a specific field to do the search?
>

Feel free to submit a pull request. Alternatively, you can specify both a 
custom search menu and a custom search function via the "search_widget" and 
"searchable" arguments, respectively. For ideas on the former, see 
SQLFORM.search_menu, and for the latter, see SQLFORM.build_query.

Anthony

-- 
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