Error Datatable Button: Uncaught Unknown button type: print

I have a very strange problem with the print button on a datatable. I could not find a solution.

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

I am currently working on a ruby ​​on rails project, including with datatables with the jquery-datatables-rails gemstone, version 3.3.0.

In addition, I include a CSS and JS file for the buttons, referencing the file path in the asset pipeline ( dataTables.buttons.min and buttons.datatables.min.css ).

All files are downloaded without any problems or error messages. Initializing work with data as well, but then I will add the following option:

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

for the initializer, it fails with the error message below:

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

Unfortunately, I could not find anyone who had the same problem on the Internet.

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

Also, when I try to use the excel button instead of the print button, an error message does not appear, but the button does not appear.

div.dt-buttons remains empty.

How can i solve this?

+5
source share
2 answers

You need to include this file:

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

For other problems, such as Excel, the corresponding asset files may not be present in your case. Check the list of JS files included in this example for reference.

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

The list is listed on the Javascript tab of the example.

+6
source

I suggest that you should enable the print button extension on your page.

From the docs :

These buttons are not part of the main library, but are separate files that can be included as needed. For example, you can provide HTML5 file export buttons, but not Flash export buttons. This simply ensures that only the required code is delivered to the end user.

+3
source

Source: https://habr.com/ru/post/1246401/


All Articles