Show/Hide Datatable Based on Button Click

Show/Hide Datatable Based on Button Click

rajivchodisetti54rajivchodisetti54 Posts: 8Questions: 4Answers: 0

HI ,

I have a UI with 2 search boxes , based on the type of button click event , some datatables has to be made hidden and others need to be projected in their place .

I have created a button click event and function like below and in the firebug console , I couldn't see any errors , but still it's not working ,

<button class="btn btn-primary" type="button" id="col-button" name="col-button" onclick="refresh_col()">

function refresh_col()
{
//var table_name = document.getElementById("col-query").value;
$("#oTable").hide();
$("#oTable1").hide();
}

Thanks & Regards,
Rajiv

Answers

  • rajivchodisetti54rajivchodisetti54 Posts: 8Questions: 4Answers: 0

    HI ,

    I have just now tried the below code and it's working , but I want' to switch particular datatables on and off , so how to select those particular ones and turn them off and on .

    please throw some light on it

    var tables = $.fn.dataTable.fnTables(true);
    $(tables).each(function ()
    {
    var otable = $(this).dataTable();
    $(this).dataTable().fnDestroy();
    otable.hide();
    otable.parents('div.dataTables_wrapper').first().hide();
    } );

This discussion has been closed.