Can an action be added to an already extended button?

Can an action be added to an already extended button?

chboccachbocca Posts: 86Questions: 13Answers: 1

I think the answer is no, but thought I'd ask to double-check ...

buttons: [
                      
{ extend: 'columnToggle',
  columns: '.position',

  action: function ( e, dt, node, config ) {

    // do something in addition to toggling '.position' columns

   }
                            
},

],

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,640Questions: 1Answers: 10,092 Site admin
    Answer ✓

    Yes, but it will override the original action. You'd need to call the action of the original button as shown in the last example on the buttons.buttons.action page.

    Allan

  • chboccachbocca Posts: 86Questions: 13Answers: 1
    edited February 2018

    Sweet. Thank you Alan.

    In mean time, I was resigned to doing something like this ...

    buttons: [
    
     { text: 'Toggle Position Column Plus Do Something Else',
      
       action: function ( e, dt, node, config ) { 
       
        this.active( ! this.active () ); 
        
        dt.column( '.position' ).visible( ! dt.column( '.position' ).visible() );
        
        // do something in addition to toggling '.position' column
       
       }
      
     },
    
    ],
    
This discussion has been closed.