Button extend copy with action

Button extend copy with action

TomTom1TomTom1 Posts: 2Questions: 2Answers: 0

Hello,

I would like to add an action to a Copy button and keep the default comportement as well. I succedded for a Copy as HTML5 but the basic Copy did generate an issue ($.fn.dataTable.ext.buttons.copy.action being undefined).
A scenario has been uploaded in a zip.
Can you tell me how to solve this case ?
Thank you in advance.

Regards.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,272Questions: 1Answers: 10,212 Site admin
    Answer ✓

    In the action for the button you should be able to do something like:

    new $.fn.dataTable.Buttons( table, {
        buttons: [
            { 
                extend: 'copy',
                action: function ( e, dt, node, config ) {
                    // Do custom processing
                    // ...
     
                    // Call the default copyHtml5 action method to do the standard copy
                    $.fn.dataTable.ext.buttons.copyHtml5.action.call(this, e, dt, node, config);
                }
            }
        ]
    } );
    

    See buttons.buttons.action.

    Allan

Sign In or Register to comment.