DataTable() method redraws table with wrong config

DataTable() method redraws table with wrong config

wallabe123wallabe123 Posts: 24Questions: 13Answers: 0

My web page has multiple tabs, each tab has a different table on it. I am using the below lines of code to readjust the table when its tab is clicked on:

var table = $('#example').DataTable();
table.columns.adjust().draw();

The first line seems to be redrawing the table with default config, for example I have removed the paging length drop down from the table on its initialization but this line of code adds it back in.

Is there a way to 'refresh' the table using the configuration I set up at the start when it was first loaded in?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    Answer ✓

    Line 1 will initialize a new Datatable if it hasn't been initialized already. If it has been initialized then line 1 will only return an API instance. Your description suggests that the code to initialize without page length, etc is either not executed or executed after the above statements.

    Verify your execution order with the browser's debugger. If you still need help then please post a link to 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

Sign In or Register to comment.