clear datatable initialize once data is fetch

Solutions on MaxInterview for clear datatable initialize once data is fetch by the best coders in the world

showing results for - "clear datatable initialize once data is fetch"
Olivia
20 Jul 2019
1if you're using DataTables 1.10.x, you can initialize the new table with
2additional option "destroy": true, see below : 
3
4function fetchNews(context)
5{
6     if(context!="")
7     {
8        $("#dailyNews").dataTable({
9            "destroy": true,
10            // ... skipped ...
11        });
12    }
13}
14
15OR
16
17For older versions :
18
19function fetchNews(context)
20{
21     if(context!="")
22     {
23        // Destroy the table
24        // Use $("#dailyNews").DataTable().destroy() for DataTables 1.10.x
25        $("#dailyNews").dataTable().fnDestroy()
26
27        $("#dailyNews").dataTable({
28           // ... skipped ...
29        });
30    }
31}