Show/Hide Columns without indices
Show/Hide Columns without indices

Hi,
I need to collapse/show columns by class name as my columns are dynamic based on user preferences.
This questions has been asked before, but the discussion was closed, hence a new discussion.
I found an old discussion with what I needed.
http://datatables.net/forums/discussion/2546/showhide-columns-without-column-index-reference/p1
The solution below:
var detailedView = false;
function toggleColumns() {
detailedView = !detailedView;
var table = $('#myTable').dataTable();
$.each(table.fnSettings().aoColumns, function (index, value) {
if (value.nTh.classList.contains("toggle"))
table.fnSetColumnVis(index, detailedView);
});
}
Does not work in IE 8 for me, works in Firefox though.
The IE error is: Unable to get value of the property 'contains': object is null or undefined"
Any ideas/workarounds?
Thank you,
Meghna
I need to collapse/show columns by class name as my columns are dynamic based on user preferences.
This questions has been asked before, but the discussion was closed, hence a new discussion.
I found an old discussion with what I needed.
http://datatables.net/forums/discussion/2546/showhide-columns-without-column-index-reference/p1
The solution below:
var detailedView = false;
function toggleColumns() {
detailedView = !detailedView;
var table = $('#myTable').dataTable();
$.each(table.fnSettings().aoColumns, function (index, value) {
if (value.nTh.classList.contains("toggle"))
table.fnSetColumnVis(index, detailedView);
});
}
Does not work in IE 8 for me, works in Firefox though.
The IE error is: Unable to get value of the property 'contains': object is null or undefined"
Any ideas/workarounds?
Thank you,
Meghna
This discussion has been closed.
Replies