How to populate a Vertical / inverted Table

How to populate a Vertical / inverted Table

ZeussZeuss Posts: 4Questions: 3Answers: 0
edited February 2016 in Free community support

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

  • mRendermRender Posts: 151Questions: 26Answers: 13

    You need a tbody in order for Datatables to work.

  • ZeussZeuss Posts: 4Questions: 3Answers: 0

    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!

This discussion has been closed.