> def on_define_product(table): 
>     if 'product' in request.function :
>         if table.signoff == 'No':
>             table.signoff.represent = lambda signoff, field: SPAN(signoff, 
> _class = 'text-error')
>         elif table.signoff == 'Yes':
>             table.signoff.represent = lambda signoff, field: SPAN(signoff, 
> _class = 'text-success')
>

Note, Sarbjit wants to format *each row* differently, depending on the 
values in the row. The above cannot do that. First, in the above function, 
table.signoff is a dal.Field object. The Field object does not have a value 
of "No" or "Yes", so neither branch above will ever execute. Second, the 
relevant logic must be applied separately to each Row selected from the 
database, so the logic cannot go in an on_define function, which is called 
only once when the table is defined. Rather, the logic must go in the 
"represent" function itself, which is called separately for each Row.

Anthony

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to