function toggleIt() { var indices = []; $("#myTable tbody tr").first().children("td.myclass").each(function(){ indices.push($(this).index()); }); alert("indices:" + indices); for(var ind in indices) { var iCol = indices[ind]; var bVis = oTable.fnSettings().aoColumns[iCol].bVisible; oTable.fnSetColumnVis( iCol, bVis ? false : true ); } }
When I run toggleIt(), I get
"indices: 4,6,7"inside alert dialog box. Then 4,6 and 7th columns are hidden.
When I run toggleIt() again I get an empty indices array.
When I check DOM, I see that 4,6 and 7th columns are deleted.
Does "fnSetColumnVis" deletes the columns? Is it possible to just hide rather than delete the data?