Ayesha Fathima

Ayesha Fathima

  • NA
  • 184
  • 30.1k

Refresh Data table with new data set

Feb 6 2018 11:32 PM
Hi, i am initiating data table on onclick of table column values,there iam calling one service from that service output iam forming data set and setting it to data table.
If u click on one column value for the first time it is showing some data related to that row,But after that iam clicking on another row in that column only it is showing previous data set.Data table is not getting refreshed with fresh data.Iam using function to refresh data table,but it is not working.If iam not putting this line "retrieve: true," it is showing error like cannot reinitialize data table.
How can i refresh with new data set values??
 
 
  1. $('#attachmenttable').DataTable( {  
  2.              retrieve: true,//need to write this line otherwise it wil throw an error like "cannot reinitialize data table"  
  3.              paging: false,  
  4.              searching:false,  
  5.         data: combinedarray,  
  6.         columns: [  
  7.             { title: "File Name",visible:true,"render"function ( data, type, row ) {  
  8.                         return '<a href="javascript:void(0)" onclick="opendetails('+"'"+row[1]+"'"+",'"+row[0]+"'"+')">' + data + '</a>';  
  9.                       }},  
  10.             { title: "Base64",visible:false }  
  11.         ]  
  12.     } );  
  13.       
  14.     function refreshTable() {  
  15.     $('#dataTables-attachmenttable').DataTable({  
  16.     responsive: true,  
  17.         "paging":   false,  
  18.         "info":     false,  
  19.         "searching" : false,  
  20.         "order": [[ 1, "desc" ]]  
  21. });}  
  22.   
  23. setInterval(refreshTable , 1000 );  
 

Answers (1)