button().collectionRebuild()
Rebuild a buttons collection.
Please note - this property requires the Buttons extension for DataTables.
Description
This function is used to change, or update the contents of a collection button. This makes it possible to effortlessly add buttons to collections without having to redeclare the collection button.
Type
button().collectionRebuild( buttons )
Rebuild the contents of the buttons collection based on the array that is passed in.
Parameters:
Name | Type | Optional | |
---|---|---|---|
1 | buttons | Yes | |
An array that is full of objects, strings or functions that are used to create buttons. Please refer to |
Returns:
DataTables.Api
DataTables API instance with the selected button in the result set, available for chaining further operations on the button.
Examples
Add excel button to collection:
var table = new DataTable('#myTable', {
buttons: [
{
extend: 'collection',
text: 'print',
buttons: ['csv', 'pdf']
}
]
});
table.button(0).collectionRebuild(['csv', 'pdf', 'excel']);
Remove csv button from collection:
var table = new DataTable('#myTable', {
buttons: [
{
extend: 'collection',
text: 'print',
buttons: ['csv', 'pdf']
}
]
});
table.button(0).collectionRebuild(['pdf']);
Empty collection:
var table = new DataTable('#myTable', {
buttons: [
{
extend: 'collection',
text: 'print',
buttons: ['csv', 'pdf']
}
]
});
table.button(0).collectionRebuild([]);