thank you very much Anthony. You are SUPER.

Il giorno lunedì 15 ottobre 2018 14:31:28 UTC+2, Anthony ha scritto:
>
> def custom_search(fields, keywords):
>     [generate a DAL query based on fields and keywords]
>     return query # Will eventually be used like db(query).select(...)
>
> grid = SQLFORM.grid(..., searchable=custom_search)
>
> The "fields" argument is a list of the DAL field objects from the table 
> used to generate the grid (i.e., same as [f for f in db.mytable]), and 
> "keywords" is the "keywords" string from the URL query string.
>
> Anthony
>
> On Monday, October 15, 2018 at 2:39:33 AM UTC-4, Andrea Fae' wrote:
>>
>> Thank you Anthony, but the code is not easy to understand. could you make 
>> me an easy example about to create a custom search function? Do I have to 
>> write the code in my controller default.py? Or do I have to change the code 
>> in the standard file sqlhtml.py (I don't think so).
>> Thank you
>>
>> Il giorno lunedì 15 ottobre 2018 04:08:51 UTC+2, Anthony ha scritto:
>>>
>>> The "searchable" argument can be a function that takes the list of 
>>> fields in the grid and the submitted keywords and returns a DAL Query 
>>> object, so you can create a custom search function. For an example, see the 
>>> default search function: 
>>> https://github.com/web2py/web2py/blob/master/gluon/sqlhtml.py#L2043.
>>>
>>> Anthony
>>>
>>> On Sunday, October 14, 2018 at 4:05:43 PM UTC-4, Andrea Fae' wrote:
>>>>
>>>> Hello, in a grid, if you type searchable=True default) you can search 
>>>> by EVERY field in the grid. But I want to use the search box not to all 
>>>> fields in te view, but only in some of them. Is it possible or I have to 
>>>> create a specific search form? Can you send me some example?
>>>> Thank you
>>>>
>>>

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