Twitter: raymondcamden


Address: Lafayette, LA, USA

The new oddness (and evenness) of Spry 1.4

12-19-2006 2,780 views Comments

Ok, I'm not sure if "evenness" is really a word, but if Steve Colbert can make stuff up - so can I. Before Spry 1.4, Spry supported a simple way to apply different CSS styles to datasets rows to support even/odd colors. It was done using the built in variable ds_EvenOddRow. On execution, this would be replaced with even or odd. So in this example:

view plain print about
1<tr spry:repeat="dsEmployees" class="{ds_EvenOddRow}">

You would end up with this when the dataset was generated:

view plain print about
1<tr class="even">
2...
3<tr class="odd">

If you wanted different names, you could prepend or append a value to the class like so:

view plain print about
1<tr spry:repeat="dsEmployees" class="myds_{ds_EvenOddRow}">

While this worked, it wasn't the cleanest method. Spry 1.4 introduces a new spry:even and spry:odd tag. This allows you to specify the class to use in each particular case. Consider this example:

view plain print about
1<tr spry:repeat="dsEmployees" spry:even="even" spry:odd="odd">

This ends up being the exact same as the first example, but is a bit more clear.

One more quick example. If you are repeating over multiple datasets, you can tell spry:even and spry:odd what dataset to check for "oddness". Adobe provides an example of that.

So to see live examples of all of these, visit:

http://labs.adobe.com/technologies/spry/samples/data_region/EvenOddRowSample.html

0 Comments

Post Reply

Please refrain from posting large blocks of code as a comment. Use Pastebin or Gists instead. Text wrapped in asterisks (*) will be bold and text wrapped in underscores (_) will be italicized.

Leave this field empty