{hero}

buttons.buttons.text

Since: Buttons 3.0.0

The text to show in the button.
Please note - this property requires the Buttons extension for DataTables.

Description

Being able to let your users know what will happen when they activate a button is obviously fundamentally important to the Buttons extension and this option provides exactly that ability.

Types

string

Description:

An HTML string to be shown inside the button. This is written to the document as plain HTML, so HTML can be used for additional formatting.

function text( dt, node, config )

Description:

The buttons.buttons.text buttons option can be defined as a function that will be executed when Buttons requires the text for the button. This provides the ability for plug-in authors to make use of i18n() to easily provide internationalisation support for the text shown in buttons. It could also potentially be used for other complex interactions such as counting the number of selected rows.

Parameters:
Returns:

The string to be displayed for the buttons visual text

Default

  • Value: Dependent on button type

Examples

Set the text of a button:

new DataTable('#myTable', {
	layout: {
		topEnd: {
			buttons: [{ extend: 'copy', text: 'Copy to clipboard' }]
		}
	}
});

Internationalisation using the i18n() method::

new DataTable('#myTable', {
	layout: {
		topEnd: {
			buttons: [
				{
					extend: 'print',
					text: function (dt, button, config) {
						return dt.i18n('buttons.print', 'Print');
					}
				}
			]
		}
	}
});

Instance initialisation: Highlight an action key using HTML:

new DataTable.Buttons(table, {
	buttons: [
		{
			extend: 'print',
			text: '<em>P</em>rint',
			key: {
				key: 'p',
				altkey: true
			}
		}
	]
});