Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82819

How to export actual data after javascript update?

$
0
0

Hello!
I use DataTable to export spreadsheet to excel and pdf.
My table is updated by Ajax. But without using DataTable. After filtering or paging, non-updated data is exported. Those that were in the table when the page was loaded and the DataTable was initialized.
table.rows (). invalidate ('dom'). draw (); also brings the table to its original form.
table.destroy (); and re-initialization also inserts the original data. I ask for help, I will be very grateful.

My code is:

 <script>
    $(document).ready(function() {
        
         var table;
         init_table();
        
    $('#update_d').on("click", function(){
        
     update_data();
        
    })
        
} );
 
     function init_table(){
         
       setTimeout(function(){ 
       table = $('.datagrid_wrapper > table').DataTable( {
        dom: 'Bfrtip',
        paging: false,
        searching: false,
        bRetrieve: true,
        info: false,
        buttons: [
             'csv', 'excel', 'pdf', 'print'
        ]
    });
   },1000);  
         
     }
     
     function update_data(){
         
     table.rows().invalidate('dom').draw();
         
     }
     
</script>

Viewing all articles
Browse latest Browse all 82819

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>