Alternate Colors for row blocks

Hello.

I need to do a twist on the alternate row colors. I looked at cycle(),
but that appears to be table row specific.

I have a table header. Then I have up to 3 table rows that are grouped
together in a loop. I’d like to alternate colors per group, not per
row. If I put the 3 table rows into a separate table, it makes a mess
out of my table and table header.

Any ideas?

Thanks.

On Mar 11, 2008, at 12:33 PM, Becca G. wrote:

out of my table and table header.

Any ideas?

Thanks.

So something like:

class=“<%= cycle(‘green’, ‘green’, ‘green’, ‘white’, ‘white’, ‘white’)
%>”>

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Rob B. wrote:

class="<%= cycle(‘green’, ‘green’, ‘green’, ‘white’, ‘white’, ‘white’)
%>">

Thanks for the suggestion, but I’m not sure this will work in my
situation.

There is always going to be a first(x) and second(y) row. The third(z)
row may be populated based on the results of the second row. If “y”
finds a record, then the “z” row created with a value . If “y” does not
find a value, then it ends the loop and goes to the next “x” record.

Additionally I have the records split into 3 rows.

The code looks similar to this.

<% for x in @x.id %>

<%=h x.id %> <%=h y.id %> <%# if y returns a value %> <%=h z.id %> <% end %>

Becca G. wrote:

<%=h x.id %> <%=h y.id %> <%# if y returns a value %> <%=h z.id %> <% end %>

Call "cycle’ only once inside each loop, such as…

<% for x in @x.id %>
<% row_group_class = cycle(‘green’,‘white’) %>

><%=h x.id %> ><%=h y.id %> <%# if y returns a value %> ><%=h z.id %> <% end %>


http://www.5valleys.com/
http://www.workingwithrails.com/person/8078

Jon G. wrote:

Call "cycle’ only once inside each loop, such as…

<% for x in @x.id %>
<% row_group_class = cycle(‘green’,‘white’) %>

><%=h x.id %> ><%=h y.id %> <%# if y returns a value %> ><%=h z.id %> <% end %>

That’s perfect! Thanks!!!