Hi,
I try to use virtual fields as in example
http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=virtual#New-style-virtual-fields
db.item.total_price = Field.Virtual('total_price',
lambda row: row.item.unit_price *
row.item.quantity)
But how can I list virtual field in grid fields?
grid=SQLFORM.grid(db.item.id>0, fields=[db.item.unit_price,
db.item.total_price ] )
gives error
web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback
Traceback (most recent call last):
File "/home/jurgis/dev/web2py_src/gluon/restricted.py", line 227, in
restricted
exec ccode in environment
File
"/home/jurgis/dev/web2py_src/applications/app/controllers/plugin_search_form.py"
<http://localhost:8001/admin/default/edit/app/controllers/plugin_search_form.py>,
line 247, in <module>
File "/home/jurgis/dev/web2py_src/gluon/globals.py", line 417, in <lambda>
self._caller = lambda f: f()
File
"/home/jurgis/dev/web2py_src/applications/app/controllers/plugin_search_form.py"
<http://localhost:8001/admin/default/edit/app/controllers/plugin_search_form.py>,
line 50, in test_virtual_field
grid=SQLFORM.grid(db.item.id>0, fields=[db.item.unit_price,
db.item.total_price ] )
File "/home/jurgis/dev/web2py_src/gluon/sqlhtml.py", line 2758, in grid
value = row[str(field)]
File "/home/jurgis/dev/web2py_src/gluon/packages/dal/pydal/objects.py",
line 76, in __getitem__
raise KeyError
KeyError
ps.: listing all fields would work, but I don't need all :
grid=SQLFORM.grid(db.item.id>0 )
or should I use readable = False for the ones I want to hide?
--
Jurgis Pralgauskis
tel: 8-616 77613;
Don't worry, be happy and make things better ;)
http://galvosukykla.lt
--
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.