buttons()
Select one or more buttons.
Please note - this property requires the Buttons extension for DataTables.
Description
The Buttons extension provides a powerful set of selector options so you can select which buttons to perform actions upon. This is very similar to the core DataTables rows()
, columns()
and cells()
which provide the ability to select elements from the table, and more generally like jQuery selectors, so you will be immediately familiar with this interface.
Using the button-selector
parameter it is possible to select one or more buttons that you wish to perform an operation on (for example changing the display text or enabling and disabling the button).
If no parameters are passed in, all buttons in all collections are selected.
Additionally, as it is possible to have multiple instances of the Buttons extension attached to a single DataTable, the button-group-selector
option can be optionally included to select buttons from one or more button sets.
Type
function buttons( [ groupSelector, ] buttonSelector )
- Description:
Select one or more buttons from the button instances attached to a DataTable.
- Parameters:
Name Type Optional 1 groupSelector
Yes Button group (instance) selector. Provides the ability to select buttons from one or more instances of the Buttons class.
By default this is
undefined
resulting in all instances attached to the DataTable being selected.2 buttonSelector
No Selector to obtain the buttons that should be acted upon.
- Returns:
DataTables API instance where the result set contains information about the selected buttons so operations can be chained.
Examples
Disable all buttons with the class 'csv':
var table = new DataTable('#myTable');
table.buttons('.csv').disable();
Change the text for button indexes 2 and 2-0:
var table = new DataTable('#myTable');
table.buttons([2, '2-0']).text('Not available');
Select and disable all buttons from instance index 0:
var table = new DataTable('#myTable');
table.buttons(0, null).disable();
Enable all buttons with the class export
from the instance with the name output
:
var table = new DataTable('#myTable');
table.buttons('output:name', '.export').enable();