buttons.buttons.text

Since: Buttons 1.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 using $().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

DataTables initialisation: Set the text :

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

Instance initialisation: Highlight an action key using HTML:

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

Internationalisation using the i18n() method::

new $.fn.dataTable.Buttons( table, {
	buttons: [
		{
			extend: 'print',
			text: function ( dt, button, config ) {
				return dt.i18n( 'buttons.print', 'Print' );
			}
		}
	]
} );