Dynamically Toggling Between Responsive and Horizontal Scrolling View in DataTables
Dynamically Toggling Between Responsive and Horizontal Scrolling View in DataTables
aryeb
Posts: 2Questions: 1Answers: 0
Hello everyone,
I need the ability to switch between the responsive view and horizontal scrolling view dynamically, based on a particular event (e.g., a button click). I'd also like to have the option to switch back to the responsive view when needed.
Could anyone provide guidance or point me to resources on how to achieve this dynamic toggling between views in DataTables?
DT v-1.13.6
Answers
Both of those are initialisation options, so you would need to
destroy()
(ordestroy
) the table and recreate it again with the desired options. You could usestateSave
to keep the filtering/ordering/pagination of the previous table.Colin
I appreciate the help. When I use the destroy() method, I encounter an error. The error message can be seen in the screenshot linked below:
Subsequently, the page turns blank. Any guidance would be appreciated.
Its hard to say why you are getting the error without seeing what you have done.
Here is a simple example:
https://live.datatables.net/yihavutu/1/edit
It uses
DataTable.isDataTable()
to determine if the Datatable has been initialized before usingdestroy()
.If you still need help please post a link ot your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin