hide show column by class name instead of data-column

hide show column by class name instead of data-column

usernetusernet Posts: 12Questions: 6Answers: 0
edited October 2014 in Free community support

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

  • usernetusernet Posts: 12Questions: 6Answers: 0
    edited October 2014

    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 :/

  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin

    Can you link to a test case showing the issue please.

    Allan

This discussion has been closed.