Need help on Export csv and xl not exporting all Data
Need help on Export csv and xl not exporting all Data
This is my code for datatable and export button:
$(document).ready(function(){
var dataTable = $('#user_data').DataTable({
"sDom": "Rlfrtip",
"fixedHeader": true,
"processing":true,
"serverSide":true,
"order":[],
"ajax":{
url:"<?php echo base_url() . 'admin/fetch_store'; ?>",
type:"POST" ,
"data":function(data) {
data.country = $('#country').val();
data.state = $('#state').val();
data.city = $('#city').val();
data.email = $('#email').val();
data.contact_number = $('#contact_number').val();
data.activity = $('#activity').val();
data.start_date = $('#start_date').val();
data.end_date = $('#end_date').val();
},
},
"columnDefs":[
{
"targets":[0, 12 ],
"orderable":false,
},
]
});
// Download Button
var table = $('#user_data').DataTable();
var buttons = new $.fn.dataTable.Buttons(table, {
buttons: [
// 'excelHtml5',
// 'csvHtml5'
{
extend: 'excelHtml5',
footer: false,
exportOptions: {
columns: [0,1,2,3,4,5,7,8,9,10]
}
},
{
extend: 'csvHtml5',
footer: false,
exportOptions: {
columns: [0,1,2,3,4,5,7,8,9,10]
}
}
]
}).container().appendTo($('#buttons'));
//
$('#search').on( 'click', function (event) {
event.preventDefault();
//
var email = $('#email').val();
var contact_number = $('#contact_number').val();
if(email!=''){
if(validateEmail(email)==false){
$("#error_email").html("<div class='text-danger'>please enter valid email!</div>");
$("#email").focus();
return false;
}
}
//
var start_date = $('#start_date').val();
var end_date = $('#end_date').val();
if(start_date=='' || end_date=='')
{
dataTable.draw();
}
else if(start_date <= end_date) {
dataTable.draw();
}
else {
alert("Your start date can not be less than end date!");
return false;
}
} );
Answers
Hi @taslim12 ,
This looks like a duplicate of your other thread to me, so closing off: https://datatables.net/forums/discussion/51164/export-csv-and-xl-is-exporting-only-page-1-data-i-need-all-data#latest .
Cheers,
Colin