Sorry the previous email did not contain the final version. Here it is.

def search_form(self,url): 
    form = FORM('', 
  
INPUT(_name='keywords',_value=request.get_vars.keywords, 
               _style='width:200px;', 
               _id='keywords'), 
         INPUT(_type='submit',_value=T('Search')), 
         INPUT(_type='submit',_value=T('Clear'), 
         _onclick="jQuery('#keywords').val('');"), 
         _method="GET",_action=url) 

    return form 

def search_query(tableid,search_text,fields): 
    words= search_text.split(' ') if search_text else [] 
    query=tableid<0#empty query 
    for field in fields: 
        new_query=tableid>0 
        for word in words: 
            new_query=new_query&field.contains(word) 
        query=query|new_query 
    return query 

Then in the function that has the sqlform.grid call, before the call 
add 

    search_text=request.get_vars.keywords 
    query=search_query(db.tablea.id,search_text, 
[db.tablea.fielda,db.tablea.fieldb])   

-- 



Reply via email to