CityDesk 2.0-Documentation
Alternating StylesIf you are using a forEach loop to create a table, you may want to use alternating styles or colors for odd and even rows to make it easier to read the table. This can be accomplished using the {$ odd $} and {$ even $} sections inside the loop itself. Any text in the odd section will appear for the 1st, 3rd, and 5th records, and so on. Any text in the even section will appear for the 2nd, 4th, and 6th records, and so on.
For example, suppose we had a folder named People containing these items:
We can display them in an HTML table with alternating blue and yellow backgrounds using the following HTML code:
<table>
{$foreach x in (folder "People")$}
{$even$}
<tr><td bgcolor=lightblue>{$x.fileName$}</td></tr>
{$odd$}
<tr><td bgcolor=yellow>{$x.fileName$}</td></tr>
{$next$}
</table>This will produce the following table:
Ivan Smith Joe Nguyen Ken Thomas Lester Johnson Moe Williams Norm Wang Ollie Lee Peter Stephenopoulous
©Copyright 2001-2003 Fog Creek Software, Inc. All Rights Reserved.