Last active
January 1, 2016 01:59
-
-
Save atstockland/8076687 to your computer and use it in GitHub Desktop.
Create a nested iteration that spans two table header rows. The idea is to have the upper row show the model aircraft, and then under that group show the school aircraft that are in that group.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% @models.each_with_index do |m, index| %> | |
<th class="center-text model_column_span" colspan="<%= current_school.helicopters.active.joins{ helimodel }.where{ helimodel.nickname.eq( m ) }.order("helimodels.nickname asc").length %>"><%= m %></th> | |
<%= "(#{@models.length-1} - #{index}), " %> | |
<% if @models.length-1 == index %> | |
<%= "</tr> <tr>".html_safe %> | |
<% end %> | |
<th class="time">Time</th> | |
<% @aircraft.where{ helimodel.nickname.eq(m) }.each_with_index do |aircraft, column_index| %> | |
<th class="center-text" id="column_<%= column_index %>"><%= aircraft.name %></th> | |
<% end %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This works. But, requires more code and only allows for styling the colspans in the top row...so, cant draw around both rows to section off the aircraft that go with the model. | |
<thead> | |
<tr> | |
<th></th> | |
<% @models.each do |m| %> | |
<th class="center-text model_column_span" colspan="<%= current_school.helicopters.active.joins{ helimodel }.where{ helimodel.nickname.eq( m ) }.order("helimodels.nickname asc").length %>"><%= m %></th> | |
<% end %> | |
</tr> | |
<tr> | |
<th class="time">Time</th> | |
<% @aircraft.each_with_index do |aircraft, column_index| %> | |
<th class="center-text" id="column_<%= column_index %>"><%= aircraft.name %></th> | |
<% end %> | |
</tr> | |
</thead> |
Actually, I don't think is gonna do what I want...even if this worked
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I could just have two separate iterations over two separate tows. Which I already did...but, what Im after is the ability to style the blocks of aircraft and their associated aircraft model header.