3

I am using v1.10.6, when I changed the display for a datatable Container, all rows become collapsed. I tried to use:

oTable.responsive.recalc();

and:

oTable.columns.adjust().responsive.recalc();

Also I tried:

$($.fn.dataTable.tables(true)).DataTable().responsive.recalc();

but it's removing the responsive functionality of the table.

1 Answer 1

8

Yes, your problem was easy to reproduce. A basic responsive: true initialisation does in fact collapse the rows when the table is shrinked, but does not expand the rows when the table is enlarged, and seems not to work at all if you make the table larger than its original size.

But setting autoWidth: false seems to do the trick :

var table = $('#example').DataTable({
    autoWidth: false, //<---
    responsive : true
});

window.onresize = function() {
    table.columns.adjust().responsive.recalc();
}    

Now it seems to work as it supposed to do.
Demo -> http://jsfiddle.net/g0vhvcp7/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.