On Wednesday, July 12, 2017 at 5:28:03 AM UTC-4, Pranshul Chitransh wrote: > > Thanks for the prompt reply Anthony! Actually this is not quite I was > looking for. I meant to include the 'does not contain' option in the > pre-defined filters that grid already has in its UI. Let me know if the > question is not clear. >
There is no built-in way to do that. You can put a "not" or "~" at the beginning of the query to achieve the desired search result: not mytable.myfield contains "some string" But there is no way to include a "not contains" option in the search menu. You can, however, create a custom search widget via the "search_widget" argument. The default widget is the SQLFORM.search_menu static method, so maybe start with the source code from that method and tweak it to get what you want. Also, note that by default, the search query produced by the search widget is processed by the SQLFORM.build_query static method, which ultimately calls the smart_query() function in the pydal.helpers.methods module for queries using the advanced search syntax. However, you can create a custom query builder by specifying a function as the "searchable" argument to the grid. You can use modified versions of SQLFORM.build_query and pydal.helpers.methods.smart_query to, for example, support syntax such as "mytable.myfield not contains". 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

