When you provide a list of fields, only those fields are selected, so the
"id" field will not be available in each record, causing the represent
function to fail. The alternative is to include the "id" field as well but
set its "readable" attribute to False so it doesn't appear in the grid.
Anthony
On Wednesday, July 8, 2015 at 6:30:16 PM UTC-4, Alex Glaros wrote:
>
> If I add a "fields" statement in grid, this error arises:
>
> 'Row' object has no attribute 'id'
>
> db.SuperObject.objectDisplayName.represent = lambda value, r:
> A(db.SuperObject(r.SuperObject.id).objectDisplayName,
> _href=URL('re_direct_specific_object', args=r.SuperObject.id,
> vars=request.vars))
> grid = SQLFORM.grid(query, details=False, deletable=False,
> create=False, editable=False, fields=[db.SuperObject.objectDisplayName])
>
> If I comment out fields statement, it works with correct reference
> redirect via the "represent" statement
>
> db.SuperObject.objectDisplayName.represent = lambda value, r:
> A(db.SuperObject(r.SuperObject.id).objectDisplayName,
> _href=URL('re_direct_specific_object', args=r.SuperObject.id,
> vars=request.vars))
> grid = SQLFORM.grid(query, details=False, deletable=False,
> create=False, editable=False) #, fields=[db.SuperObject.objectDisplayName])
>
> If I comment out the represent, the field statement works
>
> #db.SuperObject.objectDisplayName.represent = lambda value, r:
> A(db.SuperObject(r.SuperObject.id).objectDisplayName,
> _href=URL('re_direct_specific_object', args=r.SuperObject.id,
> vars=request.vars))
> grid = SQLFORM.grid(query, details=False, deletable=False,
> create=False, editable=False, fields=[db.SuperObject.objectDisplayName])
>
> anyone see syntax errors?
>
> thanks
>
> Alex Glaros
>
--
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.