I am using SQLFORM.grid. I'd like to classify data with colors, for example:
________________________________________________________________
| If data in first row is type A | I'd apply the green
color to row. |
-----------------------------------------------------------------------------------------------------------------
| If data in second row is type B | I'd apply the red color
to row. |
-----------------------------------------------------------------------------------------------------------------
And so on.
I am using the advice explained in other questions:
customized = myformat(grid.rows)
grid.element('.web2py_table', replace=customized)
Where my customize function is:
def myformat(rows):
#import gluon
#nuevo = gluon.dal.Rows()
new = DIV()
for i in rows:
if i.account.startswith('A'):
# in this section I need to paint the row in green
i.account = ('<div style="color:green;">' + i.account + '</div>'
) #my try
elif i.account.startswith('B'):
# in this section I need to paint the row in red
i.account = ('<div style="color:red;">' + i.account + '</div>')#my
try
new.insert(0, i)
return new
However I am getting only string data:
<Row {'type': '<div style="color:green;">A</div>}> <Row {'type': '<div
style="color:red;">B</div>}>
I don't know what kind of value I must return from myformat function. Rows
or DIV. Which way should I go?
--
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.