selectRow checkboxes

This commit is contained in:
Corban-Lee Jones 2024-04-24 09:26:27 +01:00
parent 7be8bc936a
commit 319d8d59de

View File

@ -14,13 +14,14 @@ function initSubscriptionTable() {
},
columnDefs: [
{ orderable: false, targets: "no-sort" },
// {
// targets: 0,
// checkboxes: { selectRow: true }
// }
{
targets: 0,
checkboxes: { selectRow: true }
}
],
columns: [
{
{
// Select row checkbox column
title: "",
data: null,
orderable: false,
@ -48,16 +49,10 @@ function initSubscriptionTable() {
orderable: false,
className: "text-center",
render: function(data, type) {
var check = $('<input type="checkbox" class="form-check-input" />');
check.prop("checked", data);
return check[0]
return `<input type="checkbox" class="form-check-input" ${data ? "checked" : ""} />`
}
},
],
createdRow: function(row, data, dataIndex) {
// Insert checkbox in the first cell of each row
$(row).find('td:eq(0)').html('<input type="checkbox" class="form-check-input" />');
}
]
});
subTable.rows.add([
@ -105,11 +100,6 @@ $("#subTable tbody").on("change", "tr td:first-child .form-check-input", functio
if (selected) row.select();
else row.deselect();
// $('#subTable tbody tr:not(.selected) td input[type="checkbox"]').prop("checked", false);
// $('#subTable tbody tr.selected td input[type="checkbox"]').prop("checked", true);
// subTable.rows(".selected").select();
// subTable.rows(":not(.selected)").deselect();
});
// Select all rows checkbox