var table = $('#table_id').DataTable({
dom : 'Bfrtlip',
columnDefs: [{
targets:[1],//指定哪几列
render: function(data){
return "\u200C" + data ;
}
}]
});
$(document).ready(function() {
var buttonCommon = {
exportOptions: {
format: {
body: function ( data, row, column, node ) {
// Strip $ from salary column to make it numeric
return column === 5 ?
data.replace( /[$,]/g, '' ) :
data;
}
}
}
};
$('#example').DataTable( {
ajax: '../../../../examples/ajax/data/objects.txt',
columns: [
{ data: 'name' },
{ data: 'position' },
{ data: 'office' },
{ data: 'extn' },
{ data: 'start_date' },
{ data: 'salary' }
],
dom: '<"#btn_id"B>frtip',//可在此设置下载的按钮的id和样式等
buttons: [
$.extend( true, {}, buttonCommon, {
extend: 'copyHtml5'
} ),
$.extend( true, {}, buttonCommon, {
extend: 'excelHtml5'
} ),
$.extend( true, {}, buttonCommon, {
extend: 'pdfHtml5'
} )
]
} );
} );