0

I've got a data which comes in json format and I would like to draw a table using jquery based on it. However, I would like to display the data as columns rather than rows. So for example,

instead of doing

  <tr><td>   </td> <td>    </td></tr> 

to add a cell for each row I would like to be able to insert data in the columns, say sth like

   $("#table tr:gt(0) td:last").append("<td>" + "value" + "</td>"); 

This should insert an item to the bottom of column 0 or at least this is what I need. This is simply because the columns won't have the same length of items. So I would like to fill in the columns and not the rows.

george
  • 3,102
  • 5
  • 34
  • 51
  • possible duplicate of [rotate a table 90 degrees](http://stackoverflow.com/questions/6515475/rotate-a-table-90-degrees) – Roamer-1888 Nov 24 '14 at 14:38
  • No, the question is not the same. I don't want to rotate the table, I would like to be able to insert data in columns rather than building my table by rows – george Nov 24 '14 at 14:41
  • It is the same. Build the table rows in the normal way, then transpose to make rows into columns and *vice versa*. – Roamer-1888 Nov 24 '14 at 14:45
  • My data columns won't have the same items. I don't want to convert data rows to columns etc. This has nothing to do with what I am asking – george Nov 24 '14 at 14:48
  • Then rephrase the question. – Roamer-1888 Nov 24 '14 at 14:49
  • BTW, I think you are being put off by that question's bad worded title. The OP didn't really want to rotate his table but to transpose it, which is exactly what you appear to be asking for. – Roamer-1888 Nov 24 '14 at 14:53
  • Don't use tables. Use `ul` instead of and style the list like you want. Talking seriously, don't use tables. EDIT: [Some references](http://www.chromaticsites.com/blog/13-reasons-why-css-is-superior-to-tables-in-website-design) – sospedra Nov 24 '14 at 15:02

0 Answers0