Responsive DataTables plus buttons colVis

Responsive DataTables plus buttons colVis

j.stadterj.stadter Posts: 1Questions: 1Answers: 0

Hi,

I'm currently struggling with combining responsive datatables with the buttons colVis extension.
In case the table is too small and the responsiveness hides several columns, you can still show/activate them
by the buttons colVis extension which leads the table to expand and destroy the layout.
Is it possible to disable 'showing' hidden columns that would lead the table to react like this?

Tried this:

    $('#table').on('column-visibility.dt', function(e, settings, column) {
        if ($('#table tbody').width() > $('.mainpage').width()) {
            $('#table').DataTable().column(column).visible(false, false);
        }
    });

where .mainpage is the container that contains the table.

With some window resolution this works really well and with some it results in:
Uncaught RangeError: Maximum call stack size exceeded

Thank you!

This discussion has been closed.