JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
<table id="fooTable" class="table table-hover">
<thead>
<tr>
<th>Id</th>
<th>Serial</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
JavaScript
// FOO DATA FOR THE TABLE
var data = [
{ "id": "Foo1", "text": "Foo2", "action": "Foo3" },
{ "id": "Foo4", "text": "Foo5", "action": "Foo6" }
];
// DATATABLES DEFINITION, HARDCODES LAST COLUMN
var myTable = $('#fooTable').dataTable({
"columnDefs": [
{ "targets": [ 2 ],
"data": null,
"defaultContent": '<a href=# class=action-view>FooText3</a>'
}
],
columns: [
{ data: 'id' },
{ data: 'text' }
],
data: data
});
// HERE THERE SHOULD BE THE FUN STUFF WHERE USERS
// CLICKS ON ITEM OF CLASS action-view AND YOU HAVE ID FIELD
var myTableApi = $('#fooTable').DataTable();
var ID = 0;
$('#fooTable').on('click','.action-view',function() {
alert('BAZINGA!');
ID = myTableApi.row($(this).parents('tr').first()).data()[0];
alert(' ID=#'+ID+'#');
});