Topic: Where to calculate the rowspan

Hi,

I am a newbe on rails. I read some documentation and I like the concept of Models, Views, and Controllers, but I am still a bit confused where to put which code.
Therefore I would like to ask an advice on the following situation:

I have a database table that looks like this:

Col1    Col2    Col3
ABC    123    XXX
ABC    123    YYY
ABC    789    TTT
EFD    678    MMM

I would like to produce the following html table:

<table border="1">
<tr>
  <td rowspan="3">ABC</td>
  <td rowspan="2">123</td>
  <td>XXX</td>
</tr>
<tr>
  <td>YYY</td>
</tr>
<tr>
  <td>789</td>
  <td>TTT</td>
  </tr>
<tr>
  <td>EFD</td>
  <td>678</td>
  <td>MMM</td>
</tr>
</table>

I do not know on forehand how many columns in the rows are identical, in other words, I need to calculate the rowspan during the processing of the table. My question is what is the best approach? Should I put all the code for this in the View?
Please help me.

Thanx for your answer

Re: Where to calculate the rowspan

Hi Udin,

Your message is a little cryptic, at least to me. Maybe you can give us more concrete examples of what you are trying to do. What are you modeling? What are the objects and attributes involved? Use phrases like "i am trying to group by such and such," and use some actual data like "Joe" instead of XXX. Especially, use the actual names of the fields instead of Col1 and Col2, etc. This is object-oriented programming and giving us (me?) raw data and an end-result of how you want to format it is insufficient to help you. I, for one, would be happy to help you out with your problem.

If you haven't done so already, you might also benefit from running through one of the many tutorials on-line to teach yourself the basics of rails.

Re: Where to calculate the rowspan

Hi Udin,

I know what you mean, but this is not really Application Theory and Design. I suggest reposting your question in Rails Programming, you'll get much better response wink.

Alex

Re: Where to calculate the rowspan

Hi,

Sorry that I am not clear enough for you. At this moment I do not have any concrete examples yet. I am still in an investigation phase, so for me this is just a way to understand the boundaries of the (rails) views, models and condolers.
At this moment I am building ASP sites using vbscript. For a problem I used in my example I would use a database view to do all the counting for me so I do not have to loop through the database records to count them at the scrip side.
What I try to understand what the most efficient way is to do this in rails (especially when the database is not running on the same server as web-server and you want to avoid too much database traffic on the network)
Maybe my confusion is confusing you and I should just start with it. In the documentation I read most example are only strait forward and therefore less dynamic than what (I think) I need. :-)