Different number of colums
Different number of colums

Is it possible to output different number of columns depending on resolution. For example 1 column at 375px, 2 columns at 768, and 4 at 1920? Do I need to create four tables with different number of columns, or can I somehow recalculate?
Link to test case: http://ashamil.net/
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Sounds like you will want to use the Responsive Extension. You can specify the column breakpoints using Class Logic.
Kevin
Thanks for the quick response! I took advantage of your answer. But in this case, the columns become hidden along with the data. What needs to be done for the table to be dynamically recalculated?
Yep, /Responsive removes some columns to make the important ones fit the display area.
Please can you explain when you mean by that,
Colin
When the breakpoint is hit, the table looks like
Is it possible for something like:
Datatables doesn't have anything builtin to restructure the columns like this. It would take custom coding on your part to restructure the table. At a high level you will need to use
destroy()
and reinitialize the Datatable with the new column structure. Restructure the data to fit the new column structure and then apply the resturctured data to the table.Maybe a combination of the Responsive ability to immediately show the row details, see this example. And a custom child row renderer, as shown in this example, will display the data the way you want.
Kevin
And in this regard, another question
Is it possible to customize the filling of the table with a simple one-dimensional array? Instead of passing:
send:
Or is it impossible and you must always transfer data with a strictly specified size?
No, it must be two-dimensional. With a one dimensional array, how would you know where the next record begins? It needs two dimension so each record is held within an array.
Colin