collection
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, in addition to those options which are available for all buttons (e.g. buttons.buttons.text
):
Name | Type | Default |
---|---|---|
action | ||
Show the collection | ||
align Since: 1.6.0 | dt-container | |
The horizontal alignment of the popover relative to the button. It may be one of:
| ||
autoClose Since: 1.1.2 | false | |
Automatically close the collection when a button inside the collection is activated. | ||
background | true | |
Show ( | ||
backgroundClassName | dt-button-background | |
Class name to add to the background element if it is enabled. | ||
buttons | [] | |
The buttons to show in the collection. The elements in this array follow the same rules as the | ||
className | buttons-collection | |
The button's class name. See | ||
collectionLayout | ||
Layout options for the buttons shown in the collection. This is a string which can have:
The column layout can be use with the default absolute positioning of the drop down, or with the fixed position layout option. To use fixed positioning and multi-column layout, simply space separate the options - e.g. | ||
collectionTitle Since: 1.5.4 | ||
Deprecated in Favour of popoverTitle - will be removed version 3.0.0 A text string to show at the top of a collection. This can be useful for multi-level collections to ensure the end user knows what the current menu refers to. | ||
dropup | false | |
When | ||
fade | 400 | |
Animation speed that the collection is faded in and out of the display. This is an integer value that represents the animation duration in milliseconds. For no animation use the value | ||
popoverTitle Since: 2.0.0 | ||
A text string to show at the top of a collection. This can be useful for multi-level collections to ensure the end user knows what the current menu refers to. | ||
postfixButtons | undefined | |
A list of buttons that should be postfixed to an existing collection (see the | ||
prefixButtons | undefined | |
A list of buttons that should be prefixed to an existing collection (see the | ||
span Since: 2.2.2 | container | |
Match the width of the dropdown to the datatables container.:
| ||
text | Collection | |
The button's display text. The text can be configured using this option (see |
Example
DataTables initialisation: Create an export collection:
new DataTable('#myTable', {
layout: {
topStart: {
buttons: [
{
extend: 'collection',
text: 'Export',
buttons: ['csv', 'excel', 'pdf']
}
]
}
}
});