Hi!!!

1°) I am using autocomplete widget in this manner

    db.tpersona.idprovincia.widget = SQLFORM.widgets.autocomplete(request, 
db.trprovincia.descripcion,
                                                                  id_field=
db.trprovincia.id, limitby=(0,20), min_length=2 )

This works, but I would like searching in midle of string, for example  in 
descripcion= "Santa Cruz" when I am typing 'Cru', the widget would must 
show "Santa Cruz". Any suggestion?

2°) Also I was triying the next receipe: 
http://www.web2pyslices.com/slice/show/1391/jquery-autocomplete-widget

response.files.append(URL(r=request,c='static/jquery-autocomplete',f='jquery.autocomplete.js'))
response.files.append(URL(r=request,c='static/jquery-autocomplete',f='jquery.autocomplete.css'))

def get_items():
    itms = []
    if request.vars.q and request.vars.table and request.vars.field:
        q = request.vars.q
        f = request.vars.field
        t = request.vars.table
        fld = db[t][f]
        rows = 
db(fld.upper().like("%"+q.upper()+"%")).select(fld,distinct=True) 
        itms = [str(t[f]) for t in rows] 
    return '\n'.join(itms)

def autocomplete_widget(f,v):
    import uuid
    
    d_id = "autocomplete-" + str(uuid.uuid4())[:8]
    get_url = URL(r=request,c='default',f='get_items')
    wrapper = DIV(_id=d_id)
    inp = SQLFORM.widgets.string.widget(f,v)
    scr = SCRIPT('jQuery("#%s 
input").autocomplete("%s",{extraParams:{field:"%s",table:"%s"}});' % \
                  (d_id, get_url,f.name,f._tablename))
    
    
    wrapper.append(inp)
    wrapper.append(scr)
    return wrapper

def abmpersona():
    query = (db.tpersona.id > 0)

    db.tpersona.idprovincia.widget = 
autocomplete_widget(db.trprovincia.descripcion,db.trprovincia.id)

    grid = SQLFORM.grid(query,field_id = db.tpersona.id)
    return locals()


*But I get  ticket:*

Error ticket for "Tester"
Ticket ID
127.0.0.1.2017-05-10.08-44-36.08989307-1cf8-4970-b9d8-632c417c8ab8

<type 'exceptions.TypeError'> 'DIV' object is not callable

Versión
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47
Python Python 2.7.13: /usr/bin/python (prefix: /usr)
Rastreo
14.
Traceback (most recent call last):
  File "/home/jalbornoz/web2py/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/home/jalbornoz/web2py/applications/Tester/controllers/default.py", 
line 99, in <module>
  File "/home/jalbornoz/web2py/gluon/globals.py", line 417, in <lambda>
    self._caller = lambda f: f()
  File "/home/jalbornoz/web2py/applications/Tester/controllers/default.py", 
line 96, in abmpersona
    grid = SQLFORM.grid(query,field_id = db.tpersona.id)
  File "/home/jalbornoz/web2py/gluon/sqlhtml.py", line 2303, in grid
    create_form = SQLFORM(table, **sqlformargs)
  File "/home/jalbornoz/web2py/gluon/sqlhtml.py", line 1286, in __init__
    inp = field.widget(field, default)
TypeError: 'DIV' object is not callable
Error snapshot  help
<type 'exceptions.TypeError'>('DIV' object is not callable)

Any idea why this error is generated?

*Regards.*

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