Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datatables: export button not working

I try to do dynamically change filename and change other variable after click export button. But it seem the new release got problem inside button.html5.js. Can anyone help me with this thing. Here is the error image and the link of my code.

enter image description here

buttons:    [{
              extend: 'excel',
              text:   'Excel',
              action: function (e, dt, node, config) {
                        exportExtension = 'Excel';

                        $.fn.DataTable.ext.buttons.excelHtml5.action(e, dt, node, config);
                      }
               }]

JsFiddle

like image 659
saf21 Avatar asked Jun 17 '26 15:06

saf21


1 Answers

This is a scoping issue. The action method needs to be executed in the scope of the Buttons instance so it can access method attached to this. In this case you need to use:

$.fn.DataTable.ext.buttons.excelHtml5.action.call(this, e, dt, node, config);

See also this thread on the DataTables forums on the same topic with this answer and a working test case.

Allan

like image 68
Allan Jardine Avatar answered Jun 20 '26 09:06

Allan Jardine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!