JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://datatables.net/release-datatables/media/css/jquery.dataTables.css">
<link rel="stylesheet" href="http://datatables.net/release-datatables/extensions/TableTools/css/dataTables.tableTools.css">
<script src="http://datatables.net/release-datatables/media/js/jquery.js"></script>
<script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js"></script>
<script src="http://datatables.net/release-datatables/extensions/TableTools/js/dataTables.tableTools.js"></script>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$320,800</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>63</td>
<td>2011/07/25</td>
<td>$170,750</td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Junior Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$86,000</td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Senior Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$433,060</td>
</tr>
<tr>
<td>Airi Satou</td>
<td>Accountant</td>
<td>Tokyo</td>
<td>33</td>
<td>2008/11/28</td>
<td>$162,700</td>
</tr>
<tr>
<td>Brielle Williamson</td>
<td>Integration...
JavaScript
$(document).ready(function() {
$('#example').DataTable( {
dom: 'T<"clear">lfrtip',
tableTools: {
"sRowSelect": "single",
"aButtons": [
{
sExtends:"text",
sNewLine: "<br/>",
sButtonText: "edit",
fnClick: function (nButton, oConfig, oFlash) {
alert('click');
},
fnComplete: function (nButton, oConfig, oFlash, sFlash) {
alert('finish');
},
fnSelect: function(nButton, oConfig, nRow){
// replicates the behaviour of the select_single button
var iSelected = this.fnGetSelected().length;
if ( iSelected == 1 ) {
$(nButton).removeClass( this.classes.buttons.disabled );
} else {
$(nButton).addClass( this.classes.buttons.disabled );
}
// "do something" is output twice.
console.log("[edit button's fnSelect()] do something");
// row_data = this.fnGetSelectedData()[0]);
// so this would be a problem...
// do some function(row_data){}
},
},
],
}
});
});