Custom Editor button that's enabled before selecting a row

Custom Editor button that's enabled before selecting a row

jacktrapjacktrap Posts: 14Questions: 6Answers: 0
edited June 2019 in Free community support

Hello, I've been using the custom buttons in this fashion:

$('#myTable').DataTable( {
    buttons: [
        {
            extend: 'selectedSingle',
            text: 'Log selected data',
           action: function ( e, dt, button, config ) {
                console.log( dt.row( { selected: true } ).data() );
           }
        }
    ]
} );

And they're great. But I need one for Creating a new row, but they're always disabled by default. I can't find in the documentation where to have a custom button that's enabled before clicking a row?

This question has an accepted answers - jump to answer

Answers

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

    Hi @jacktrap ,

    It's because you're extending selectedSingle, which only activates when a single row is selected. If you remove that line, like here, it's always activated.

    Cheers,

    Colin

This discussion has been closed.