hide show column by class name instead of data-column
hide show column by class name instead of data-column
hi every body i implement the script that hide / show column https://github.com/DataTables/DataTables/blob/master/examples/api/show_hide.html
it works perfectly but when i change column number by class name column it just hide column i cant' reappeare it again :/
this is my code
<a class="toggle-vis" data-column="numero">Numéro</a>
var table = $('#example').DataTable( {
"scrollY": "200px",
"aoColumnDefs": [ { "sClass": "hide_column", "aTargets": [ "id" ] } ],
"paging": false
} );
$('a.toggle-vis').on( 'click', function (e) {
e.preventDefault();
// Get the column API object
var column = table.columns("." + $(this).attr('data-column') );
// Toggle the visibility
column.visible( ! column.visible() );
} );
Answers
i replaced table.columns with table.column it works now but only for the first column :/ :/
when i click on any link only the first column that appear and desappear :/
Can you link to a test case showing the issue please.
Allan