Daly
2006-Nov-29 17:43 UTC
Formatting a 2 Dimensional Array on Screen without Using Tables
Hello all, I have an array=[rows][columns] which I would like to display on screen without using tables. I have 3 columns. I tried doing this: <% row.start.upto.(row.end) do |number| %> <div id="left"><%= array[number][0]%></div> <div id="middle"><%= array[number][1]%></div> <div id="right"><%= array[number][2]%></div> <br /> <% end %> But this resulted in only the last row to be displayed. So I tried doing 3 loops similar to this: <div id="left"> <% row.start.upto.(row.end) do |number| %> <p><%= array[number][0]%></p> <% end %> </div> This resulted in displaying the whole array, but since the contents vary in length, some of them would be rendered on more than one line, and some not, resulting in it not looking like a grid at all. Can anyone help me with this? I successfully did it with tables, but was wanting to do it via css. Thanks, Ahmed --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thorsten L
2006-Nov-29 18:11 UTC
Re: Formatting a 2 Dimensional Array on Screen without Using Tables
tries something like this ? <% array.each do |columns| %> <div id="left"><%= columns[0]%></div> <div id="middle"><%= columns[1]%></div> <div id="right"><%= columns[2]%></div> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daly
2006-Nov-29 18:25 UTC
Re: Formatting a 2 Dimensional Array on Screen without Using Tables
This produces the same result as the first code group. Only one line is shown. That line is the result of the last iteration. Thanks. On Nov 29, 1:11 pm, "Thorsten L" <duple...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> tries something like this ? > > <% array.each do |columns| %> > <div id="left"><%= columns[0]%></div> > <div id="middle"><%= columns[1]%></div> > <div id="right"><%= columns[2]%></div> > <% end %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jwcooper
2006-Nov-29 18:32 UTC
Re: Formatting a 2 Dimensional Array on Screen without Using Tables
Why not do it with tables? This seems perfectly reasonable to do it with tables due to it being a grid. I think all those divs are going to make it a lot more messy than a table would be in the markup. My 2 cents. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Daly
2006-Nov-29 18:43 UTC
Re: Formatting a 2 Dimensional Array on Screen without Using Tables
A perfectly good question :) I was trying to create a totally table-less page. I guess somethings cannot be done without using them and that css has its limitations. Thanks. I''ll stick to tables for this particular view. Regards, Ahmed On Nov 29, 1:32 pm, "jwcooper" <jwcoo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Why not do it with tables? > > This seems perfectly reasonable to do it with tables due to it being a > grid. > > I think all those divs are going to make it a lot more messy than a > table would be in the markup. > > My 2 cents.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---