How to populate a Vertical / inverted Table
How to populate a Vertical / inverted Table
What is the correct syntax for vertical table. Meaning the column headers are in a row and the data is in each column.
I defined the table in HTML like
HEADER1 | data | data |
HEADER2 | data | data |
HEADER3 | data | data |
script
$('myTable').Datatable({
"select": false,
"dom": 't',
"ajax": { url:url },
"columns": [
{ "data": "data1" },
{ "data": "data2" },
{ "data": "data3" },
]
});
I am getting error in JS. I think its looking for thead and tbody. How do I display inverted table?
Answers
You need a tbody in order for Datatables to work.
OK I found the solution. Just make a regular table with thead and tbody as you would make for a horizontal one and apply css style
table.verticalDisplay thead {
float: left;
}
table.verticalDisplay thead th {
display: block;
}
table.verticalDisplay tbody {
float: right;
}
table.verticalDisplay tbody td {
display: block;
}
This did the trick!