Hi
I've read the docs on dynamically hiding/showing columns but there are 2 things it doesn't cover:
1. What is the recommending approach for customising column headers so that I can exclude an 'X' image to hide the column
2. How do I get the column number so that I can call oTable.fnSettings().aoColumns[iCol].bVisible;. It is possible by matching the text in the column header as below but it seems clunky and horrible:
I've read the docs on dynamically hiding/showing columns but there are 2 things it doesn't cover:
1. What is the recommending approach for customising column headers so that I can exclude an 'X' image to hide the column
2. How do I get the column number so that I can call oTable.fnSettings().aoColumns[iCol].bVisible;. It is possible by matching the text in the column header as below but it seems clunky and horrible:
$('.dataTable thead th').dblclick(function(){ var oTable = $('#programtable').dataTable(); var iCol = 0; var myText = $(this).text(); console.log(oTable.fnSettings().aoColumns); $(oTable.fnSettings().aoColumns).each(function(myvar, myval) { console.log(iCol + 'is ' +myval.sTitle); if (myval.sTitle == myText) { return false; } iCol++; }) var bVis = oTable.fnSettings().aoColumns[iCol].bVisible; oTable.fnSetColumnVis( iCol, bVis ? false : true ) });