In a previous post I showed a solution for a more google like search for 
SQLFORM.grid - " sqlform.grid *search* 
*widget*<https://groups.google.com/forum/?fromgroups=#!searchin/web2py/search$20widget/web2py/9_1ECdKHKUo/-KRWzsr01cIJ>
".

I have now extended this to allow alphabetic searches by clicking on the 
appropriate letter of the alphabet.

First modify the search to search on the first letter when the search text 
is a single letter.

    search_text=request.get_vars.keywords
    if (search_text==None or len(search_text)<>1):
        
query=search_query(db.artists.id,search_text,[db.artists.name,db.artists.description])
    else:
        query=db.artists.name[0]==search_text.upper()    

Then add the following to the view

<br>
{{for i in range(0,26):}}
{{=A(chr(i+ord('A')),_href=URL('mycontroller','myfunction',vars=dict(keywords=chr(i+ord('A')))))}}
{{pass}}

-- 



Reply via email to