{hero}

buttons.buttons.action

Since: Buttons 1.0.0

Action to take when the button is activated.
Please note - this property requires the Buttons extension for DataTables.

Examples

Custom action functions:

new DataTable('#myTable', {
	layout: {
		topStart: 'buttons'
	},
	buttons: [
		{
			text: 'Alert',
			action: function (e, dt, node, config, cb) {
				alert('Activated!');
				this.disable(); // disable button
			}
		}
	]
});

Create a custom button that uses a built in button's action method:

new DataTable('#myTable', {
	layout: {
		topStart: 'buttons'
	},
	buttons: [
		{
			text: 'Create CSV',
			action: function (e, dt, node, config, cb) {
				// Do custom processing
				// ...

				// Call the default csvHtml5 action method to create the CSV file
				DataTable.ext.buttons.csvHtml5.action.call(this, e, dt, node, config, cb);
			}
		}
	]
});