{hero}

button().collectionRebuild()

Since: Buttons 2.0.0

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

function button().collectionRebuild( buttons )

Description:

Rebuild the contents of the buttons collection based on the array that is passed in.

Parameters:
Returns:

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([]);