Here's one way to do it. Note that when I start having this kind of 
problems I usually stop using the grid and make a custom solution.  
  
In the grid, the searchable argument, can be a function. In that case it 
gets the fields and keywords and its responsibility is to generate and 
return a query. You can disable advanced_search and then only have a search 
field. Then you will have a searchable function which will detect if one of 
the keywords entered in the search is a date, if that is the case then you 
will make a query where only records from that date are acceptable.

Your controller function would be something like this:

def mygrid():
    import datetime


    def searchable(fields, keywords):
        query = db.my_table.id > 0:
        for keyword in keywords:
            date = None
            try:
                date = datetime.datetime.strptime(keyword,'%Y-%m-%d')
            except ValueError:
                pass
            if date:
                query &= db.my_table.created_on == date
            else:
                # this is just an example
                query &= db.my_table.name.like('%' + keyword + '%', 
case_sensitive=False)
        return query


    return {'grid': SQLFORM.grid(db.my_table, searchable=searchable, 
advanced_search=False)}


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