In my DataTable, I have added some HTML export buttons. I want to change the HTML button name and want to display an icon on the button. How can I do it?
I have followed with this code:
$(document).ready( function () { $('#MyDataTable').DataTable({ dom: 'Bfrtip', buttons: [{ extend: 'pdf', },{ extend: 'excel', }, { extend: 'csv', } ] }); } );
To add icon and text in DataTable html button apply this code:
$(document).ready( function () { $('#MyDataTable').DataTable({ dom: 'Bfrtip', buttons: [{ extend: 'pdf', text: '<i class="fa fa-file-pdf-o" aria-hidden="true"></i> PDF', },{ extend: 'excel', text: '<i class="fa fa-file-excel-o" aria-hidden="true"></i> EXCEL', }, { extend: 'csv', text: '<i class="fa fa-file-word-o" aria-hidden="true"></i> CSV', } ] }); } );
Hope it will be helpful for you.
Question and answer is powered by AnsPress.io