Buttons

When working with a complex DataTable it is not uncommon to wish to present options that the end user can activate to affect the table, or the data contained within the table in some manner. Displaying buttons that can be clicked, tapped or triggered from a keyboard with one method of doing this and the Buttons extension provides exactly that ability.

The various DataTables extensions provide buttons that can be used to access the functionality of that extension; Editor for example provides add, edit and delete buttons for a table. The buttons that are available are documented here. Furthermore, custom buttons can also be created to perform actions that are specific to your use case.

Buttons can be used through the buttons configuration object with dom used to specify where the buttons should be placed:

$('#myTable').DataTable( {
    dom: 'Bfrtip',
    buttons: [
        'colvis',
        'excel',
        'print'
    ]
} );

For further information about Buttons custom events, please refer to the Buttons extension documentation. Please note that DataTables core does not itself provide any buttons and the Buttons extension must be loaded in order to be able to use the buttons from the extensions.

Library Name Summary
Buttons

collection

A button which triggers a drop down with another set of buttons

Buttons

columnToggle

A single button that will toggle the visibility of one or more columns

Buttons

columnVisibility

A single button that controls the visibility of one or more columns

Buttons

columnsToggle

A set of Buttons to toggle the visibility of individual columns

Buttons

columnsVisibility

A set of Buttons to set the visibility of individual columns

Buttons

colvis

A button collection that provides column visibility control

Buttons

colvisGroup

Show and hide multiple columns

Buttons

colvisRestore

Restore the visibility of column to their original state

Buttons

copy

Copy table data to clipboard button

Buttons

copyHtml5

Copy table data to clipboard button (HTML)

Buttons

csv

Create and save a CSV file that contains the data from the table

Buttons

csvHtml5

Create and save a CSV file that contains the data from the table (HTML5)

Buttons

excel

Create and save an Excel CSV file that contains the data from the table

Buttons

excelHtml5

Create and save an Excel XLSX file that contains the data from the table (HTML5)

Buttons

pageLength

Button collection that will control the DataTables' page length

Buttons

pdf

Create and save a PDF file that contains the data from the table

Buttons

pdfHtml5

Create and save a PDF file that contains the data from the table (HTML5)

Buttons

print

Button show a printable view of the table's data

Buttons

spacer

A special "button" which provides visual grouping between buttons.

FixedColumns

fixedColumns

A single button that initialises and allows FixedColumns to be toggled.

SearchBuilder

searchBuilder

A single button that displays the SearchBuilder container in a popover.

SearchPanes

searchPanes

A single button that displays the SearchPanes container in a popover.

SearchPanes

searchPanesClear

A single button that clears the SearchPanes selections.

Select

selectAll

Select all items in the table based on the current item select mode

Select

selectCells

Change the item selection mode to cell.

Select

selectColumns

Change the item selection mode to column.

Select

selectNone

Deselect all selected items in the table.

Select

selectRows

Change the item selection mode to row.

Select

selected

Button that is enabled when one or more items are selected in the table

Select

selectedSingle

Button that is enabled when a single item is selected in the table

Select

showSelected

Toggle a filter that will reduce the rows displayed to just those which are selected.

StateRestore

createState

Creates a new state, based off of the current state of the table.

StateRestore

removeAllStates

Removes all stored states.

StateRestore

removeState

Removes a state from storage.

StateRestore

renameState

Renames a state.

StateRestore

savedStates

Collection used to provide interaction with the saved states

StateRestore

savedStatesCreate

Extends savedStates, adding creating functionality to the collection normally displayed

StateRestore

stateRestore

A split button that represents and provides functionality for a saved state.

StateRestore

updateState

Updates a selected state with the current table state.