button().active()
Get / set the active state of the selected button.
Please note - this property requires the Buttons extension for DataTables.
Description
Buttons can be placed into an "active" state which is purely a styling function to visually show to the end user that the button is active (i.e. whatever operation it performs is currently active). This can be useful if you have a number of different modes of operation that the user can select from, but only one can be active at a time.
More than one button can be "active" at any one time and the active state of each button does not effect the active state of any other button.
This method can be used to dynamically change the active state for the selected button.
Types
function button().active()
- Description:
Get the active state for the selected button.
- Parameters:
Name Type Optional 1 state
No Get the button's current active state.
- Returns:
true
if currently active, otherwisefalse
.
function button().active( state )
- Description:
Set the active state for the selected button.
- Parameters:
Name Type Optional 1 state
No Set the active state (
true
) or remove (false
).- Returns:
DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
Examples
Show button index 0 as active:
var table = new DataTable('#myTable');
table.button(0).active(true);
Toggle between buttons:
var table = new DataTable('#myTable');
table.button(0).action(function () {
this.active(true);
table.button(1).active(false);
// ... set button index 0's mode of operation
});
table.button(1).action(function () {
this.active(true);
table.button(0).active(false);
// ... set button index 1's mode of operation
});