Can an action be added to an already extended button?

Can an action be added to an already extended button?

chboccachbocca Posts: 90Questions: 14Answers: 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: 63,573Questions: 1Answers: 10,483 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: 90Questions: 14Answers: 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.