taken directly from
http://web2py.com/books/default/chapter/29/07/forms-and-validators#SQLFORM.grid-and-SQLFORM.smartgrid
links is used to display new columns which can be links to other pages. The
> links argument must be a list of dict(header='name',body=lambda row:
> A(...)) where header is the header of the new column and body is a
> function that takes a row and returns a value. In the example, the value is
> a A(...) helper.
>
so, links is a list of dicts .... [dict(), dict()]
On Friday, September 20, 2013 8:19:18 PM UTC+2, 黄祥 wrote:
>
> hi,
>
> i have an table that contain an upload field for store image, i want to
> show the image in sqlform grid. i tried to using link for achieve that, it
> works well (code 1), but there is no header on it, when i put the header
> (code 2) like describe on the book, it return an error :
> TypeError: 'str' object is not callable.
>
> *code 1 (work, but no header):*
> def product():
> links=[lambda row: A(IMG(_src=URL('download', args=row.image), _width=50,
> _height=50), _href=URL('download', args=row.image))]
> grid=SQLFORM.grid(db.product,
> *links=links)*
> #links=dict(header='image',body=[lambda row: A(IMG(_src=URL('download',
> args=row.image), _width=50, _height=50), _href=URL('download',
> args=row.image))]))
> #links=dict(header='image',body=lambda row: A(IMG(_src=URL('download',
> args=row.image), _width=50, _height=50), _href=URL('download',
> args=row.image))))
> return locals()
>
> *code 2 (not work return an error : TypeError: 'str' object is not
> callable.):*
> def product():
> links=[lambda row: A(IMG(_src=URL('download', args=row.image), _width=50,
> _height=50), _href=URL('download', args=row.image))]
> grid=SQLFORM.grid(db.product,
> #links=links)
> #links=dict(header='image',body=[lambda row: A(IMG(_src=URL('download',
> args=row.image), _width=50, _height=50), _href=URL('download',
> args=row.image))]))
> *links=dict(header='image',body=lambda row: A(IMG(_src=URL('download',
> args=row.image), _width=50, _height=50), _href=URL('download',
> args=row.image))))*
> return locals()
>
> how can i show the image with the header in sqlform.grid?
>
> thanks and best regards,
> stifan
>
--
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/groups/opt_out.