Keeping the state on show/hide columns based on user interaction
Keeping the state on show/hide columns based on user interaction
I want to maintain the state on the datatables columns based on the user turning them on or off.
I have the following code:
mytable.columns('.hide-empty').every( function () {
var column = this;
var columnData = column.data().join('');
if (columnData.length < 1) {
column.visible(false);
} else {
column.visible(true);
}
})
if the column is empty the code will auto hide the column and vice versa. If the user decides to show a column that was hidden and there is no data on refresh the column will be hidden again. Is there a way to force the state based on user interaction?
Possible solution:
Do not save the state when this code is ran but then check the state to either auto turn on or off?
Maintain the state of the column visibility.
Thanks in advance!