Thanks Anthony, just what I needed ! (.add_class method is not in the
manual)
On Sunday, 31 March 2013 14:21:57 UTC+1, Anthony wrote:
>
> Actually, here's an easier method:
>
> tr = TR(...).add_class('warning' if row.field1 == None else '')
>
> So, no need for the separate "if" statement. The .add_class() method has
> the extra benefit of working even if there is already an existing class and
> you want to add an additional one.
>
> Anthony
>
> On Sunday, March 31, 2013 9:16:32 AM UTC-4, Anthony wrote:
>>
>> Depends on what your code looks like, but in general you can add a class
>> (or other attributes) to an existing helper object as follows:
>>
>> tr = TR(...)
>> if row.field1 == None:
>> tr['_class'] = 'warning'
>>
>> Anthony
>>
>> On Sunday, March 31, 2013 8:50:42 AM UTC-4, Paul wrote:
>>>
>>> Hi, its been a while since I've used web2py, I'm sure this is easy but
>>> cannot find it in the manual:-
>>>
>>> In a view I'm generating html using the helper TR() while looping over
>>> rows from a sqlite table, I just want to add a class="warning" to some rows
>>> based on the value in a database field (e.g. if row.field1 == None then
>>> add class="warning" to this TR row, else don't add any css class to this
>>> row), so I can highlight just some of the rows with missing data.
>>>
>>> Thanks
>>>
>>>
>>>
>>
--
---
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.