buttons.buttons.text
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 ofi18n()
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:
Name Type Optional 1 dt
No A DataTables API instance for the host DataTable
2 node
No jQuery instance for the button node
3 config
No The button's configuration object
- 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
}
}
]
});