Basic initialization
This simple example shows Buttons configured with the printbutton type only. The print button will open a new window in the end user's browser and, by default, automatically trigger the print function allowing the end user to print the table. The window will be closed once the print is complete, or has been cancelled. Also you can disable auto printing option (see the example below).
Disable auto print
By default, when the print button opens the print view window it will automatically call the browser's window.print()method to present the browser's print dialogue box to the end user and they can set the options they wish. When the print action is confirmed or cancelled the print view window is then automatically closed. If this is not what you want, you can easily disable this behaviour by setting autoPrintoption to false.
Column selector
The exportOptions.columnsoption of the printbutton provides the ability to select only certain columns (using a column-selector). In this example only the visible columns are used for the printing. The column visibility buttons (colvis) are included in this example so the column visibility can be easily changed. Additionally, the last column in the table is hidden by default (columns.visible).
Row selector
The print button provides a lot of flexibility in the selection of the data that is to be exported. In this example the Selectextension for DataTables is used to give the end user the ability to select rows by clicking on them. Two print buttons are utilised in this example to demonstrate the exportOptionsoption: the firstbutton will print all rows (after filtering); the secondbutton will print only the selected rows.