Chetan Chetan - 4 years ago 189
HTML Question

How to change default name of buttons in datatable plugin?

I am using datatables plugin for by displaying data in my html page.
I have a requirement where I want to export the data inside the datatable.

Datatable supports this functionality by some plugins and a example can be seen here.

what I get on screen is that the export buttons with the fixed default names like below

enter image description here

I want to change the default names to custom names. eg. "Excel" to "Export to Excel"

How can I do that?

$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
} );
} );


In the above code if I change the default names , then my functionality breaks because datatable recognizes the functionality of button by its name. Is there any property which I should use which will help me achieve what I want or any other way out?

Answer Source

With the new version of DataTables;

buttons: [
   { 
      extend: 'copy',
      text: 'Copy to clipboard'
   }
]

Here is the example from documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download