I'm utilizing a table with jQuery.dataTables
. I have a requirement to input dates in the last column. However, when I click to input a date, the row becomes deselected.
The following code is meant for selecting all rows:
Displayed below is the DataTable setup:
var table = $('#tableRegister').DataTable({
data: [],
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
},
order: [[1, 'asc']],
columns: [
{ data: "ACTION" },
{ data: "ID" },
{ data: "REGISTER_DATE" }
],
rowCallback: function (row, data) { },
filter: false,
info: false,
ordering: false,
processing: true,
retrieve: true
});
$('#table_name tbody').on('click', 'tr', function () {
$(this).toggleClass('selected');
});
The values of the table are populated using ajax calls.
for (var i = 0; i < e.DataBadge._REG.length; i++) {
table.row.add({
"ID": e.DataBadge._REG[i]._ID,
"REGISTER_DATE": `<input type='text' class='form-control datepicker2' id='register_date${i}'/>`
}).draw();
}
Is there any way to maintain selection on the last column?