Hello everyone,
I would like to store additional information for each field in one of my
tables. I will use this information to choose the correct text colour for
each column of each record.
My end goal:
...
db.table.field.represent = lambda value, row : get_text_colour (value, row,
db.table.field)
grid = SQLFORM.grid(db.table)
return dict(grid = grid)
def get_text_colour(value, row, table):
if (table.extra[row.id] == '1'):
return SPAN(value,_style ="color:blue")
else:
return SPAN(value)
I have read this passage in the documentation:
Adding-attributes-to-fields-and-tables
<http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Adding-attributes-to-fields-and-tables>
but
I am unsure how to use it correctly.
Where do I add the following:
db.table.field.extra = {}
Every reload of my page all the values I add to the extra dictionary is
removed, so I am putting this statement in the wrong area. How do I create
this once and continually add to it?
Also, I am adding values to the extra dictionary in a function for a
computed field. Would that be a problem?
Can someone provide a small example on how to use this functionality
correctly?
Regards
--
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.