I know that to toggle the visibility in a column using the dataTables plugin I only have to do:
function fnShowHide( iCol ){
/* Get the DataTables object again - this is not a recreation, just a get of the object */
var oTable = $('#content-table-redesign').dataTable();
var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
oTable.fnSetColumnVis( iCol, bVis ? false : true );
}
but is it possible to get the column using an ID or Class or another mean?
The thing is I am also allowing the user to drag and drop the columns to will and if I go by index then they may be clicking to hide "id" (column 0) but they moved it somewhere else and now whatever is in the position 0 gets hidden instead of the "id" one.
Either that, or somehow trick the plugin to still link the column index regardless of where it's moved to.
EDIT
Here's the HTML the body is basically the same (each td has the same class as its th parent)
<table id="content-table-redesign" class="display">
<thead>
<tr>
<th class="ID">ID</th>
<th class="Name">Name</th>
<th class="Domain">Domain</th>
<th class="email">email</th>
</tr>
</thead>
<tbody>
I'm looking for the class, because the one that contains that class is the one that will be removed thead and tbody alike