Hi All,
I was customizing a SQLFORM.grid startig from the code:
model:
db.define_table('aziende',
Field('ragione_sociale', requires=[IS_NOT_EMPTY(
error_message=err_mess),
IS_NOT_IN_DB(db,
'aziende.ragione_sociale')],
),
Field('iva_cf', requires=IS_NOT_EMPTY(error_message=err_mess
)),
Field('indirizzo', 'string', label=('indirizzo'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('citta', 'string', label=T('Città'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('cap', 'string', label=T('C. A. P.'), requires=
IS_NOT_EMPTY(error_message=err_mess)),
Field('iscrizione', label=T('N° Albo Fornitori')),
Field('descrizione', 'text', requires=IS_NOT_EMPTY(
error_message=err_mess)),
Field('logo', 'upload', label=T('Logo Aziendale'),
autodelete=True,
requires=[IS_NOT_EMPTY(error_message=T(err_mess)),
IS_IMAGE(extensions=('jpeg', 'png'))
]
),
Field('brochure', 'upload', label=T('brochure Aziendale'),
autodelete=True,
requires=[IS_NOT_EMPTY(error_message=T(err_mess)),
IS_UPLOAD_FILENAME(extension='pdf')
]
),
auth.signature,
)
controller:
def aziende():
serv = [dict(header=STRONG(XML(' ' * 2), XML('Galleria Foto')),
body=lambda row: (A(SPAN(_class='icon magnifier
icon-zoom-in glyphicon glyphicon-arrow-zoom-in'),
SPAN(XML('Aggiungi/rimuovi'),
_class='buttontext
button', _title='Gestisci'),
_class='button btn btn-default', _href=
URL('gestione', 'aziende_gall', args=[row.id])),
))]
form = SQLFORM.smartgrid(db.aziende,
create=True,
editable=True,
deletable=True,
details=True,
csv=False,
paginate=30,
showbuttontext=False,
maxtextlength=43,
links=serv,
orderby=db.aziende.ragione_sociale,
sortable=True,
searchable=True,
user_signature=False,
)
if 'edit' in request.args:
response.view = 'gestione/aziende_edit.html'
if 'new' in request.args:
response.view = 'gestione/aziende_new.html'
return dict(form=form)
view:
{{extend 'layout_gestione.html'}}
<br>
<h1>Gestione Aziende</h1>
<br>
{{=form}}
into the "view" and into the "edit" view of the grid header you can see
the "the links" buttons bad rendered as shown from the image attached.
Into the file: web2py/gluon/sqlhtml.py, class SQLFORM(FORM), method
buttons()
I changed the line (about 2234)
buttons.append(link['body'](record)) with
buttons.append(link['body'](record)[0]) and this resove my bug.
Im not sure what appen when isinstance(link, dict) is false so nothing is
changed into the else block.
Greetings
Fabrizio
--
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.