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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 11, 2008, at 12:33 PM, Becca Girl wrote:> 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.So something like: class="<%= cycle(''green'', ''green'', ''green'', ''white'', ''white'', ''white'') %>"> -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rob Biedenharn 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 %> <tr><td><%=h x.id %></td></tr> <tr><td><%=h y.id %></td></tr> <%# if y returns a value %> <tr><td><%=h z.id %></td></tr> <% end %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Becca Girl wrote:> Rob Biedenharn 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 %> > <tr><td><%=h x.id %></td></tr> > <tr><td><%=h y.id %></td></tr> > <%# if y returns a value %> > <tr><td><%=h z.id %></td></tr> > <% end %> > > >Call "cycle'' only once inside each loop, such as... <% for x in @x.id %> <% row_group_class = cycle(''green'',''white'') %> <tr class=<%= row_group_class %>><td><%=h x.id %></td></tr> <tr class=<%= row_group_class %>><td><%=h y.id %></td></tr> <%# if y returns a value %> <tr class=<%= row_group_class %>><td><%=h z.id %></td></tr> <% end %> -- http://www.5valleys.com/ http://www.workingwithrails.com/person/8078 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jon Garvin wrote:> Call "cycle'' only once inside each loop, such as... > > <% for x in @x.id %> > <% row_group_class = cycle(''green'',''white'') %> > <tr class=<%= row_group_class %>><td><%=h x.id %></td></tr> > <tr class=<%= row_group_class %>><td><%=h y.id %></td></tr> > <%# if y returns a value %> > <tr class=<%= row_group_class %>><td><%=h z.id %></td></tr> > <% end %>That''s perfect! Thanks!!!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---