Answers for "datatable reinitialize"

1

reinitialize datatable on button click

$(function() {
    $('#proces_input').on('click', function() {
        alert('Im in')
        var table = $('#dt_110x_complex').DataTable({
            paging : true,
            destroy : true,    <-------Added this 
            scrollY: 300,
            ajax: "{{ url_for('complex_data') }}"
        });
    });
});
Posted by: Guest on July-12-2021
0

clear datatable initialize once data is fetch

if you're using DataTables 1.10.x, you can initialize the new table with
additional option "destroy": true, see below : 

function fetchNews(context)
{
     if(context!="")
     {
        $("#dailyNews").dataTable({
            "destroy": true,
            // ... skipped ...
        });
    }
}

OR

For older versions :

function fetchNews(context)
{
     if(context!="")
     {
        // Destroy the table
        // Use $("#dailyNews").DataTable().destroy() for DataTables 1.10.x
        $("#dailyNews").dataTable().fnDestroy()

        $("#dailyNews").dataTable({
           // ... skipped ...
        });
    }
}
Posted by: Guest on July-08-2020

Code answers related to "datatable reinitialize"

Code answers related to "Javascript"

Browse Popular Code Answers by Language