youssef hassoun youssef hassoun - 3 years ago 141
jQuery Question

how to show and hide columns of using datatable jquery

i need to show and hide the columns of the datatable after doing a javascript test , but it doesn't work good.
this is my test javascript :

if ( $('#commune_to_display').val()==""){

$('#utable td:nth-child(2)').hide();
$('#commune_to ').hide();


this test works just in the first page of the Datatable , after pagination the column still show
how can i fix it?

Answer Source

you can do using this. replace 3 and 4 with your column ID

        var table = $('#commune_to_display').dataTable();
        table.column(3).visible(true);    // To hide    
        table.column(4).visible(false);   // To Show
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download