2

I seriously searched for 3 days on this topic, but I am unable to find anything that can help me solve my issue.

I have a table that prints out Kanban cards for the factory I work in, but the Avery sheet where I need to print them is 2 col by 3 rows, and my table is displaying 3 col X 2 rows.

card 1|card 2|card 3

card 4|card 5|card 6

I need this layout to be 2 col by X rows.

card 1|card 2

card 3|card 4

card 5|card 6

This is my Rails view:

    <% count = @card.start%>
<% @card.finish.times do %>
<table border="0" cellspacing="5" cellpadding="5" class="table">
    <tr>
    <tr>
        <td id="part_no_card_no" class="all">
            <%= @card.part_no %>
            &nbsp
            &nbsp
            <%= count %> /
            <%= @card.finish %>
        </td>
    </tr>   
    <tr>
        <td>
            <%= image_tag "#{@card.part_no}" + "-" + "#{count}" + "-" + "#{@card.finish}" + ".png" %>
        </td>
    </tr>
    <tr>
        <td>
            <%= @card.description %>
        </td>
    </tr>
    <tr>
        <td>
            <%= @card.from_loc %>
            -
            <%= @card.to_loc %>
        </td>
    </tr>
    <tr>
        <td>
            Cantidad en Bin: <%= @card.bin_qty %>  EA
        </td>
    </tr>

        </td>
    </tr>

    </tr>
</table>
<% count += 1 %>
<% end %>

I hope someone could provide some direction on this task.

4
  • I am not a ruby developer, but I can tell the there is a mistake on line no: 4 <tr> should not be there and at the end on line no: 37-40 there are </td> </tr> </tr> remove that as well. These are HTML mistakes. I hope this will help you a little. Thanks Commented Feb 28, 2013 at 7:44
  • 1
    It's a little hard to follow. From what I can tell, all of your rows have exactly one column. How are you seeing 3? Commented Feb 28, 2013 at 7:47
  • 1
    this is more of a HTML thing. To have two columns in a row, keep two <td>'s inside a <tr></tr> tag eg. <tr><td></td><td></td></tr> Commented Feb 28, 2013 at 7:59
  • You want to be static table or dynamic table? If you want to have some dynamic table see my answer. Hope can help Commented Feb 28, 2013 at 10:27

2 Answers 2

2

First off, I'm not quite understand about your card system and it's attribute, since you just show some simple layout but your view looks more advance about it. So I give you an example about my code, and I will edit whenever it's needed.

I have a table named user_menus and I want to show it like: ([] mean checkbox)

[] Products     [] Suppliers
[] Categories   [] Units

I use .in_groups_of() for it.

<table class="table table-condensed">
    <% @user_menus.in_groups_of(2, false) do |user_menu_array| %>
      <tr>
        <% for user_menu in user_menu_array %>
        <td>
          <label class="checkbox">
          <%= check_box_tag "user_group[user_menu_ids][]", user_menu.id, @user_group.user_menus.include?(user_menu), :checked => true %>
          <%= user_menu.name %>
          </label>
        </td>
        <% end %>
      </tr>
    <% end %>
  </table>

With this code, I can produced that easily.

Sign up to request clarification or add additional context in comments.

1 Comment

With my solution you not needed to create your table manual anymore. This way was more DRY and simple that what I found since my user_menus was dynamic. If your card was dynamic also, I think this solution can provide you greater result lesser effort. Hope can help
0

this is more of a HTML thing. To have two columns in a row, keep two 's inside a tag eg.

e.g for 2 columns

<tr>
 <td>col-1</td>
 <td>col-2</td>
</tr>

for 4 columns

<tr>
 <td>col-1</td>
 <td>col-2</td>
 <td>col-3</td>
 <td>col-4</td>
</tr>

1 Comment

Hi Bala, thanks to all for responding by the way. So then I would have to add a condition to determine which data goes on the left and which on the right using CSS?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.