responsive-resize
The columns displayed by Responsive has changed due to a resize.
Please note - this property requires the Responsive extension for DataTables.
Description
This event can be used to inform external libraries and controls that Responsive has changed the visibility of columns in the table in response to a resize or recalculation event. This can be particularly useful if you have an external control that depends upon columns being visible or you wish to update a control based on those columns.
Type
function( e, datatable, columns )
Parameters:
Name | Type | Optional | |
---|---|---|---|
1 | e | No | |
jQuery event object | |||
2 | datatable | No | |
DataTable API instance for the table in question | |||
3 | columns | No | |
An array of boolean values that represent the state of the columns in the table. The array is exactly the same length as the number of columns in the table and a boolean |
Example
Listen for responsive resize event using on()
:
var table = new DataTable('#myTable', {
responsive: true
});
table.on('responsive-resize', function (e, datatable, columns) {
var count = columns.reduce(function (a, b) {
return b === false ? a + 1 : a;
}, 0);
console.log(count + ' column(s) are hidden');
});