The new oddness (and evenness) of Spry 1.4

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:

<tr spry:repeat="dsEmployees" class="{ds_EvenOddRow}">

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

<tr class="even"> ... <tr class="odd">

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

<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:

<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:

Like This?

If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can also subscribe to the email feed to get notified of new posts.