I'm not sure if any improvements have been made since this solution was 
originally posted, but here's a workaround: 
http://stackoverflow.com/questions/9232336/calculated-fields-in-web2py-sqlgrid/9235992#9235992

Anthony

On Monday, August 6, 2012 10:05:50 AM UTC-4, weheh wrote:
>
> I've got a table to which I'm adding a virtual field:
>
>     db.host.not_removed = Field.Virtual(lambda row:
>         db(db.url_queue.removed == None).count())
>
> I'm then using it in a grid:
>
>         list=SQLFORM.grid(
>             db.host.id > 0,
>             orderby=db.host.domain,
>             fields=[db.host.domain, db.host.categ, db.host.not_removed],
>             headers=headers,
>             deletable=False,
>             editable=False,
>             details=False,
>             create=False,
>             ui='web2py',
>             )
>
> I'm getting a ticket:
>
>   File "N:\web2py\gluon\sqlhtml.py", line 1505, in grid
>     if field._tablename in tablenames]
> AttributeError: 'FieldVirtual' object has no attribute '_tablename'
>
>

-- 



Reply via email to