How to export actual data after javascript update?
How to export actual data after javascript update?
arny88
Posts: 1Questions: 1Answers: 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>
This discussion has been closed.
Answers
Hi @arny88 ,
That looks fine if the data is being added into the DOM. We're happy to take a look. As per the forum rules, if you could link to a running test case showing the issue we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin