{hero}

buttons.buttons

Since: Buttons 1.0.0

List of buttons to be created.
Please note - this property requires the Buttons extension for DataTables.

Description

This property is an alias of the feature property buttons.buttons and can be used to configure the feature from the top level DataTables configuration object, rather than in the layout option (see example below). This lets you use the feature as a string rather than an object, but it does restrict the configuration if you were using multiple instances of the feature. Please refer to the documentation for buttons.buttons for full details and options that apply to this option.

If you are using DataTables 1.x, which does not have the layout option, use this property name, but referring to the documentation for buttons.buttons for full details.

Examples

buttons as an array using basic types:

new DataTable('#myTable', {
	layout: {
		topStart: 'buttons'
	},
	buttons: ['copy', 'csv', 'print']
});

Two buttons, one with customisations:

new DataTable('#myTable', {
	buttons: ['copy', { extend: 'excel', text: 'Save as Excel' }]
});

A fully custom button:

new DataTable('#myTable', {
	layout: {
		topStart: 'buttons'
	},
	buttons: [
		'copy',
		{
			text: 'My button',
			action: function (dt) {
				console.log('My custom button!');
			}
		}
	]
});