stanleyxu2005 stanleyxu2005 - 2 months ago 10x
Javascript Question

Switch column and rows of table

I have designed a grid using handson table. The table has roughly 15 columns (each column 100px) and only 5 rows. In total all columns will be 1500px wide, which cannot be shown on one screen, we need to use scroll bar, which is inconvenient.

I'd like to "rotate" the table, so that the table will have 6 columns

900px (150px*6)
and 15 rows
300px (20px*15)
. This will fit most screen sizes.

I have searched their doc, I have found a
, but there is no
. I'd like to know, if it is possible to do this programmatically.

Any hints are highly appreciated.


Please consider handsontable data as an 2D array. You can get handsontable data (or build your own 2D array), transpose it and then reload that returned data to handsontable.

I create a jsfiddle, so you can take a look.

Hope it helps!