Sorry i didn't mention in my previous post ,

this is also be in controller.py
def selector():
    if not request.vars.keywords:
        return ''
    pattern = request.vars.keywords + '%'
    selected = list(set([row.customer_name for row in
db((db.inward_entries.customer_name.like(pattern,case_sensitive=False))(db.inward_entries.created_by==
auth.user.id)).select(limitby=(0, 10))]))
    return ''.join([DIV(k,
                 _onclick="jQuery('#w2p_keywords').val('%s')" % k,
                 _onmouseover="this.style.backgroundColor='yellow'",
                 _onmouseout="this.style.backgroundColor='white'"
                 ).xml() for k in selected])

Thanks
Sandeep

On Fri, May 25, 2018 at 11:21 AM, Sandeep Patel <[email protected]> wrote:

>
> @isi_jca
> I have read some old threads, it seems to me that the web2py inbuild
> widget works with FORMS and *not* with the grid.
> But that's doesn't mean we can not do that. I have done so with the help
> of jQury.
>
> See my sample Code
>
> # Controller.py
> def myfuc():
> grid = SQLFROM.grid(.....)
> grid.insert(1,DIV(_style="position: absolute;background-color:
> #ffffff;border: 1px solid #1364a5",_id="suggestions",_
> class="suggestions"))
> return  locals()
> # veiw/myfuc.html
> {{ 'include layout.html'}}
> {{=grid}}
> <script>
> jQuery( document ).ready(function( $ ){
> jQuery("#w2p_keywords").keyup(function(){
> ajax('{{=URL('default', 'selector')}}', ['keywords'], 'suggestions');
> jQuery('#suggestions').click(function(){jQuery('#suggestions').hide()
> });
> });
> });
> </script>
>
> Now, this script worked for me. Just want to update you and others.
> Thanks for your advice. Greatly  appreciated
>
>
> On Fri, May 25, 2018 at 2:19 AM, isi_jca <[email protected]>
> wrote:
>
>> Sandeep:
>>
>> Look at this link: http://web2py.com/books/defaul
>> t/chapter/29/07/forms-and-validators?search=autocomplete
>> #Autocomplete-widget
>>
>> Regards
>>
>> El lunes, 21 de mayo de 2018, 9:37:40 (UTC-3), Sandeep Patel escribió:
>>>
>>> Hello,
>>> Can anyone, let me know how to work Autocomplete widget with
>>> SQLFROM.grid in the search filed. I have used Autocomplete widget in
>>> SQLFROM that's work fine but in the grid, nothing in happen.
>>>
>>>
>>> Please give me some direction how to do that.
>>>
>>>
>>> Thank's
>>> Sandeep
>>>
>>> --
>> 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.
>>
>
>

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

Reply via email to