Need help on Export csv and xl not exporting all Data
Need help on Export csv and xl not exporting all Data
![taslim12](https://secure.gravatar.com/avatar/d2cd2f3be5b256bbd7870d02b8c92c94/?default=https%3A%2F%2Fvanillicon.com%2Fd2cd2f3be5b256bbd7870d02b8c92c94_200.png&rating=g&size=120)
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