How to Re-render a table after modifying $.fn.dataTable.defaults

How to Re-render a table after modifying $.fn.dataTable.defaults

barlebybarleby Posts: 10Questions: 3Answers: 0

For a variety of reasong I have a page with 2 tables. Each one is inside a TAB content and has different configuration as they are totally different.

I do NOT have access to table initialization in javascript because my team is given a <tableComponent> which internally does the initialization.

Only way I found to alter this is via $.fn.dataTable.defaults
Problem is that with 2 tables I need to change defaults values and then re render the HTML table with these new value when I click in the table TAB.

So, is it possible to re-render a table after changing $.fn.dataTable.defaults vlaues?
I tried xxxinstance.draw() without success.

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    To change the Datatable settings you will need to use destroy() then reinitialize the Datatable.

    Kevin

  • barlebybarleby Posts: 10Questions: 3Answers: 0

    kthorngren. Thank you for the response.
    Is there any way to access the initial configuration object the table was passed in with before I destroy the instance?

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Yep, you can use the object returned by settings() - see example here.

    Colin

This discussion has been closed.