JSFiddle - React, Tailwind, and code Playground
by pehol
HTML
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/rowreorder/1.3.1/js/dataTables.rowReorder.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/rowreorder/1.3.1/css/rowReorder.dataTables.min.css">
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Seq</th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
</tr>
</thead>
</table>
JavaScript
var data = [{
"seq": "1",
"name": "Tiger Nixon",
"position": "System Architect",
"office": "Edinburgh",
},
{
"seq": "2",
"name": "Garrett Winters",
"position": "Accountant",
"office": "Tokyo",
},
{
"seq": "3",
"name": "Ashton Cox",
"position": "Junior Technical Author",
"office": "San Francisco",
},
{
"seq": "4",
"name": "Cedric Kelly",
"position": "Senior Javascript Developer",
"office": "Edinburgh",
},
{
"seq": "5",
"name": "Airi Satou",
"position": "Accountant",
"office": "Tokyo",
}
]
$(document).ready(function() {
var table = $('#example').DataTable({
data: data,
columns: [{
data: function(row, type) {
return (type == 'sort' ? row.seq : '•');
}
},
{
data: 'name'
},
{
data: 'position'
},
{
data: 'office'
}
],
rowReorder: {
dataSrc: 'seq'
}
});
});