I want to get values of a row in DataTables when a click on the button corresponding to this row, but when using this code i get undefined:
The buttons are being added like this:
function getdata()
{
$pdrs = Pdrs::select('ID_Piece', 'Designation', 'Status');
$result = DataTables::of($pdrs)
...
->addColumn('action', function($pdr){
return '<a href="#" class="btn btn-xs btn-primary Ajouter_au_panier" id="'.$pdr->ID_Piece.'"><i class="glyphicon glyphicon-shopping-cart"></i> Ajouter au panier</a>';})
->make(true);
return $result ;
}
the trigger is:
$(document).on('click', '.Ajouter_au_panier', function(){
var table = $('#pdr_table').DataTable();
console.log( table.row( this ).data() );
});
this? We need to see much more of your code in order to help you.