Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatable Button Error: Uncaught Unknown button type: print

I've got a very strange problem with the print button on a datatable I couldn't find a solution for.

The strange thing is that I've already used the print button in datatables on different pages.

At the moment I am working on a ruby on rails project, including datatables with the jquery-datatables-rails gem, version 3.3.0.

Additionally, I include the CSS and the JS file for the buttons by referencing the file path in the assets pipeline (dataTables.buttons.min and buttons.datatables.min.css).

All the files are loaded without any problem or error message. Initialising of the datatable works as well, but then I add the option below:

dom: 'Bfrtip'
buttons: [ 'print' ]

to the initializer, it causes to crash with the error message below:

Uncaught Unknown button type: print dataTables.buttons.min.js?body=1:18

Unfortunately I could not find anyone that has the same problem in the internet.

I followed the instructions on https://datatables.net/extensions/buttons/, adding the two files to my page.

Also, when I try to use the excel button instead of the print button, no error message appears, but still no button is showing up.

The div.dt-buttons stays empty.

How can I resolve this?

like image 845
Felix Letkemann Avatar asked Apr 04 '16 11:04

Felix Letkemann


2 Answers

You need to include this file :

//cdn.datatables.net/buttons/1.2.1/js/buttons.print.min.js

For other issues like Excel as well, related asset files may be missing in your case. Check the list of JS files included in this example for reference.

https://datatables.net/extensions/buttons/examples/initialisation/export.html

List is given in Javascript tab of the example.

like image 67
Gaurav Avatar answered Sep 19 '22 08:09

Gaurav


I believe you have to include the print button extension in your page.

From the docs:

These buttons are not part of the core library, but rather are individual files that can be included as you require. For example you may with to provide HTML5 file export buttons but not Flash export buttons. This simply ensures that only the code you require is delivered to the end user.

like image 22
born4new Avatar answered Sep 22 '22 08:09

born4new