How to format data and hide a column when export table to pdf
How to format data and hide a column when export table to pdf
Anamatrix
Posts: 1Questions: 1Answers: 0
Hi all,
i would like to ask how to do these two process together?
i want to format my check box data to yes or no (case 6,7), after when i export my datatable to PDF/copy/, i do not want to export all the columns.
my code can do either one only.
i want to hide my column 5, which is case 4.
Below source code is my datatable's javascript.
$(document).ready(function() {
var buttonCommon = {
format: {
body: function ( data, columnIdx, rowIdx ) {
var returnData = '';
switch (columnIdx) {
case 0: {
returnData = data;
break;
}
case 1: {
returnData = $(data).text();
break;
}
case 2: {
returnData = data;
break;
}
case 3: {
returnData = data;
break;
}
case 4: {
returnData = data;
break;
}
case 5: {
returnData = $(data).find('textarea[name=message]').val();
break;
}
case 6: {
returnData = ($(data).is(':checked')) ? "yes":"no";
break;
}
case 7: {
returnData = ($(data).is(':checked')) ? "yes":"no";
break;
}
}
return returnData;
}
}
};
var table1 = $('.dataTable').DataTable( {
paging: false,
dom: 'Bfrtip',
stripHtml: true,
buttons: [
'copy',
{extend: 'csvHtml5', text: 'CSV', exportOptions: buttonCommon,},
{extend: 'pdf', text: 'PDF', exportOptions: buttonCommon}
]
} );
} );
This discussion has been closed.