On Wednesday 10 October 2007 13:38:28 Dero wrote:
> Hello
>
> How can I change the font color of a cell in a datagrid based
> on a value there ?
>
> Pseudo example:
>
> if cell.value > 0 then cell.value.font.color = green
> else cell.value.font.color = red
You have to write your own template that is based on the datagrid-template:
<?python
def get_class_for_value(v):
if v > 0:
return "green_class"
return "red_class"
?>
<div xmlns:py="http://purl.org/kid/ns#">
<table id="${name}" class="grid" cellpadding="0" cellspacing="1" border="0">
<thead py:if="columns">
<tr>
<th py:for="i, col in enumerate(columns)" class="col_${i}">
${col.title}
</th>
</tr>
</thead>
<tr py:for="i, row in enumerate(value)" class="${i%2 and 'odd'
or 'even'}">
<td py:for="col in columns"
class="${get_class_for_value(col.get_field(row))}" >
${col.get_field(row)}
</td>
</tr>
</table>
</div>
Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---