buttons().container()
Get the container element for a single Buttons instance.
Please note - this property requires the Buttons extension for DataTables.
Description
The buttons
method of creating a new button set provides the ability to add only a single set of buttons at a time. However, Buttons has the ability to attach multiple sets of buttons to a single DataTable. This is done by creating additional button sets through the new $.fn.dataTable.Buttons()
interface. Once created, the buttons can be accessed via the DataTables API as normal.
This method is very similar to the buttons().containers()
method, in that it provides the ability to access a container element for a selected buttons instance and then insert it into the document using standard jQuery methods. However, in this case only a single Buttons instance will be included in the result. If the selector were to match multiple instances, only the first instance will be used.
When using the buttons()
selector method, the second argument (the buttons selector) is effectively ignored when processing this method. Only the button instances are used.
Type
function buttons().container()
- Description:
Get a jQuery instance that contains a reference to the button container instance.
- Returns:
jQuery instance that contains the container element for the selected button instance.
Example
Insert buttons which are created using new DataTable.Buttons()
into the document:
var table = new DataTable('#myTable');
new DataTable.Buttons(table, {
name: 'commands',
buttons: [
// ...
]
});
table
.buttons(0, null)
.containers()
.appendTo('body');