How to have an onClick event in a button cell?

How to have an onClick event in a button cell?

JochenJochen Posts: 5Questions: 3Answers: 0

Hi,

following the example at https://datatables.net/examples/ajax/null_data_source.html, I have managed to create a column with one button per cell. Good. Now I'd like to see something to happen, if I click on the button. Could someone please advise me how to do that? In a manner, which uses the data object, that has been used to create the row.

Thanks,

Jochen

Answers

  • kthorngrenkthorngren Posts: 21,171Questions: 26Answers: 4,922

    See if this thread helps.

    Kevin

  • JochenJochen Posts: 5Questions: 3Answers: 0

    Actually, it's all been in the example, I was just too stupid to note.

        $('#example tbody').on( 'click', 'button', function () {
                var data = table.row( $(this).parents('tr') ).data();
                alert( data[0] +"'s salary is: "+ data[ 5 ] );
           } );
    
This discussion has been closed.