I am doing server side processing using jquery datatable.My datatable code is as below:
$('#DataGrid').dataTable({
destroy: true,
"processing": true,
searching: false,
serverSide: true,
"scrollX": true,
"bLengthChange": false,
"iDisplayLength": pageSize,
"bInfo": true,
//stateSave: true,
order: [
[0, "desc"]
],
"aoColumnDefs": [{
'bSortable': false,
'aTargets': [(lastColumn - 1)]
}],
"dom": 'T<"clear">lfrtip',
"tableTools": {
"aButtons": [
"copy",
"csv", "xls", "pdf"
],
"sSwfPath": $("body").attr("data-project-root") + "Content/TableTools-2.2.3/swf/copy_csv_xls_pdf.swf"
},
ajax: {
url: 'StudentProgramListForIdCardResult',
type: 'POST',
data: function(d) {
d.programId = programId;
d.sessionId = sessionId;
d.branchId = branchId;
d.campusId = campusId;
d.batchName = batchName;
d.course = course;
if ($('#paymentStatus').val() > 0) {
d.paymentStatus = $('#paymentStatus').val();
} else {
d.paymentStatus = paymentStatus;
}
if ($('#imageStatus').val() > 0) {
d.imageStatus = $('#imageStatus').val();
$('#imageStatus').val();
} else {
d.imageStatus = imageStatus;
}
if ($('#printingStatus').val() > 0) {
d.printingStatus = $('#printingStatus').val();
} else {
d.printingStatus = printingStatus;
}
d.informationViewList = informationViewList;
d.batchDays = batchDays;
d.batchTime = batchTime;
}
}
});
But when I export data, TableTools is exporting the data in current page. It is not loading all data in the table.
The dataTables plugin is great and all, but the underlying table/table rows are still there in the DOM and can be traversed the same way you'd traverse any HTML table:
//foo will be a nodeList of all the tr's in the table
var foo = document.getElementById('#DataGrid').querySelectorAll('tr');
var i = 0, string = '', len = foo.length, row, cells;
for (;i<len; ++i) {
row = foo[i];
cells = row.children; //td's
string += 'however you want to package it for your ajax';
}
$.post({url: 'myServerScript', {data: string}, callback});
I was unable to easily find any documentation on a plugin-implemented appropriate export, all the export examples seem to focus on excel/csv saved to the local drive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With