{hero}

collection

Since: Buttons 1.0.0

A button which triggers a drop down with another set of buttons.
Please note - this property requires the Buttons extension for DataTables.

Description

The collection button type is integral to Buttons as it provides the ability to show one or more "sub-buttons" in a drop down that is displayed when the button is activated. This provides a method of collecting like buttons and displaying them in a space efficient manner for the end user.

The key aspect of this button type is the buttons option, which is an array of the buttons that you want to show in the drop down. The buttons defined here are exactly the same as any other button and can also be accessed via the API and manipulated as such.

Options

This button can have the following options set in its configuration object to customise its actions and display:

Examples

DataTables initialisation: Create an export collection:

$('#myTable').DataTable( {
	buttons: [
		{
			extend: 'collection',
			text: 'Export',
			buttons: [ 'csv-flash', 'xls-flash', 'pdf-flash' ]
		}
	]
} );

Direct initialisation: Collection of custom buttons:

new $.fn.dataTable.Buttons( table, {
	buttons: [
		{
			extend: 'collection',
			text: 'Flag',
			buttons: [
				{ text: 'High priority',   action: function () { ... } },
				{ text: 'Medium priority', action: function () { ... } },
				{ text: 'Low priority',    action: function () { ... } }
			],
			fade: true
		}
	]
} );