upload and sqlform.grid

66 views
Skip to first unread message

Laurent Lc

unread,
Oct 5, 2015, 10:27:01 AM10/5/15
to web2py-users
Hi,

I'd like to show pics for each records when i return a grid. My function is :

def showonly():
    query=(db1.test.present=='present')
    grid = SQLFORM.grid(query=query, user_signature=False, maxtextlength = 40,deletable=False, \
                        editable=False, create=False, details=False, \
                        links=[dict(header='picture',body=lambda row: A(IMG(_src=URL('download', args=row.picture), _width=50, _height=50), _href=URL('download', args=row.picture)))], \
                        fields=[db1.test.nom,db1.test.burtelephone,db1.test.mail,db1.test.groupe, db1.test.picture],orderby=db1.test.nom)
    return dict(grid=grid) 

The pic does not appear (header pb i think, but i follow the doc and i do not understand)
And there are 2 times the field "picture" in the columns (it works when i click on the link "file")

So i would like to have just one column "picture" whith a pic inside ....

thank you

Laurent Lc

unread,
Oct 7, 2015, 7:52:40 AM10/7/15
to web2py-users
Found :

def showonly():
    query=(db.personnel.present=='present')
    #links=[{'header':T('picture'),'body':lambda row: IMG(_src=row.picture, _width=50, _height=40, _id='picture')}]
    db.personnel.picture.represent = lambda pic,row : IMG(_src=URL('default', 'download', args=pic))

    grid = SQLFORM.grid(query=query, user_signature=False, maxtextlength = 40,deletable=False, \
                        editable=False, create=False, details=False, \
                        #links=links, \
                        fields=[db.personnel.nom,db.personnel.burtelephone,db.personnel.mail,db.personnel.groupe, db.personnel.picture],orderby=db.personnel.nom)
    return dict(grid=grid)
Reply all
Reply to author
Forward
0 new messages