JSFiddle - React, Tailwind, and code Playground
by Muhammad Mushtaq Sheikh
HTML
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.1/css/select.dataTables.min.css">
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/select/1.2.1/js/dataTables.select.min.js"></script>
<button id="btnSelectedRows">
Get Selected Rows
</button>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Product Name</th>
<th class="cell-300" scope="col" data-tablesaw-sortable-col data-tablesaw-priority="4">Product Unit</th>
<th class="cell-300" scope="col" data-tablesaw-sortable-col data-tablesaw-priority="4">Product MRP</th>
<th class="cell-300" scope="col" data-tablesaw-sortable-col data-tablesaw-priority="4">Selling Price</th>
<th class="cell-300" scope="col" data-tablesaw-sortable-col data-tablesaw-priority="4">Buying Price</th>
<th></th>
</tr>
</thead>
<tr id="C01P01">
<td></td>
<td>Name 1</td>
<td>1 Kg</td>
<td tabindex="1">50</td>
<td tabindex="2">100</td>
<td tabindex="3">150</td>
<td class="productStatus">true</td>
</tr>
<tr id="C01P02">
<td></td>
<td>Name 2</td>
<td>1 Kg</td>
<td tabindex="1">50</td>
<td tabindex="2">100</td>
<td tabindex="3">150</td>
<td class="productStatus">true</td>
</tr>
<tr id="C01P03">
<td></td>
<td>Name 3</td>
<td>1 Kg</td>
<td tabindex="1">50</td>
<td tabindex="2">100</td>
<td tabindex="3">150</td>
<td class="productStatus">true</td>
</tr>
<tr id="C01P04">
<td></td>
<td>Name 4</td>
<td>1 Kg</td>
<td tabindex="1">50</td>
<td tabindex="2">100</td>
<td tabindex="3">150</td>
<td class="productStatus">true</td>
</tr>
<tr id="C01P05">
<td></td>
<td>Name...
JavaScript
var table;
$(document).ready(function() {
table = $('#example').DataTable({
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}, {
"targets": 6,
"visible": false,
"searchable": false
}],
select: {
style: 'os',
selector: 'td:first-child'
},
order: [
[1, 'asc']
]
});
});
$('#btnSelectedRows').on('click', function() {
$.each(table.rows('.selected').nodes(), function(i, item) {
debugger;
var id = item.id;
var data = table.row(this).data();
alert("Produt Id : " +
id + " && product Status " + data[6]);
});
})