Add customize function to DataTable print button after initialization?

Add customize function to DataTable print button after initialization?

kylemhallkylemhall Posts: 2Questions: 1Answers: 0
edited February 2020 in Free community support

I'm trying to customize a web app that allows custom javascript to be added.

I'm trying to set the CSS for the print button (https://datatables.net/extensions/buttons/examples/print/customisation.html), but I cannot set the "customize" parameter of the button, because the webapp has already initialized everything.

I can access the button through JavaScript, but I tried attaching a function like this:

$(document).ready(function() {
table.buttons('.buttons-print').customize = function(){ alert("TEST") };
});

but it simply doesn't work. I'm clearly missing something.

I tried checking the source code for the print button ( https://github.com/DataTables/Buttons/blob/master/js/buttons.print.js ) but that didn't clear anything up for me.

Does anyone know if what I'm trying to accomplish is possible?

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    customize, as shown in that example, is an initialisation option - you can't change it once the table has been created.

    Colin

  • kylemhallkylemhall Posts: 2Questions: 1Answers: 0

    colin, I understand that. I'm asking if there is any way to hook up a function callback to the print button after initialization. I've delved a couple layers deep, found the config object, but can't tell if there is any way to access it through the api or some other means.

This discussion has been closed.