JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://cdn.datatables.net/t/bs-3.3.6/jqc-1.12.0,dt-1.10.11/datatables.css">
<script src="https://cdn.datatables.net/t/bs-3.3.6/jqc-1.12.0,dt-1.10.11/datatables.js"></script>
<body>
<div class="container">
<div class="row">
<table id="main" class="table table-striped table-bordered table-condensed nowrap" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th>R</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
<th>R</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>2011/04/25</td>
<td>$3,120</td>
<td></td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Director</td>
<td>Edinburgh</td>
<td>63</td>
<td>2011/07/25</td>
<td>$5,300</td>
<td></td>
</tr>
<tr>
<td>Ashton Cox</td>
<td>Technical Author</td>
<td>San Francisco</td>
<td>66</td>
<td>2009/01/12</td>
<td>$4,800</td>
<td></td>
</tr>
<tr>
<td>Cedric Kelly</td>
<td>Javascript Developer</td>
<td>Edinburgh</td>
<td>22</td>
<td>2012/03/29</td>
<td>$3,600</td>
<td></td>
</tr>
<tr>
<td>Jenna Elliott</td>
<td>Financial Controller</td>
<td>Edinburgh</td>
...
JavaScript
this.$main = $('#main').DataTable({
"orderClasses": true,
"order": [
[1, 'asc']
],
"columnDefs": [{
"targets": -1,
"render": function(data, type, full, meta) {
return '<button button type="button" class="btn btn-primary btn-sm">Remove</button>';
},
}]
});
this.$edit = $('#edit').DataTable({
"order": [
[1, 'asc']
],
"columnDefs": [{
"targets": -1,
"render": function(data, type, full, meta) {
return '<button button type="button" class="btn btn-primary btn-sm">Remove</button>';
},
}]
});
this.mainButton = function(e) {
var $tr = $(e.currentTarget).closest('tr'),
row = this.$main.row($tr),
rowData = row.data();
row.remove().draw(false);
this.$edit.row.add(rowData);
this.$edit.draw(false);
};
this.editButton = function(e) {
var $tr = $(e.currentTarget).closest('tr'),
row = this.$edit.row($tr),
rowData = row.data();
row.remove().draw(false);
this.$main.row.add(rowData);
this.$main.draw(false);
};
this.$main.on('click', 'button', this.mainButton.bind(this));
this.$edit.on('click', 'button', this.editButton.bind(this));