Search on list:reference tables with SQLFORM.Grid

40 views
Skip to first unread message

St. Pirsch

unread,
Sep 27, 2016, 5:26:56 AM9/27/16
to web2py-users

I am coming back to this topic for a second time since I couldn’t get an answer last time and it would facilitate things a lot for me:


The SQLFORM.Grid has a very sophisticated filter system to make queries over selected tables easy.

It seems, however, that it  is actually not possible to query over columns of referenced table lists. 

Is it possible - for instance - to expand the existing functionality,has anyone already worked on this and can give a hint?

Anthony

unread,
Sep 27, 2016, 9:49:06 AM9/27/16
to web2py-users
Are you talking about searching a list:reference field? If so, that wouldn't be very useful, as the end user would have to know the record IDs of the desired records. Instead, presumably you would want the ability to search based on the record representation of each reference (or some other fields within the referenced table). That certainly adds complexity and is beyond the scope of the built-in search mechanism. However, you can customize the search functionality. The "searchable" argument can be a callable that takes a list of DAL fields and the keywords submitted by the user and returns a DAL Query object. The "search_widget" argument can be used to customize the search UI on the page -- it takes a list of fields and a URL (where the search query should be sent) and should return a web2py HTML helper object (that presumably contains a form). For further details, see the source code of SQLFORM.grid in gluon.sqlhtml.

Anthony
Reply all
Reply to author
Forward
0 new messages