Columns adjust issue when using Datatable inside an accordion

0
367

If you use the shown.bs.collapse event, as the Bootstrap documentation says, it will trigger once the animation for the accordion is complete. So yes, you’d get that flicker. You need to use the show.bs.collapse event, but also with a little delay since it is triggered before the table is visible in the DOM:

$('#accordionExample').on('show.bs.collapse', function(e){
   setTimeout(function () {
      $($.fn.dataTable.tables(true)).DataTable().columns.adjust();
   }, 10);
});

LEAVE A REPLY

Please enter your comment!
Please enter your name here