multi select WIP
This commit is contained in:
parent
df01fba667
commit
523da00ce2
@ -646,7 +646,7 @@ class course extends common
|
|||||||
$userId,
|
$userId,
|
||||||
$this->getData(['user', $userId, 'firstname']),
|
$this->getData(['user', $userId, 'firstname']),
|
||||||
$this->getData(['user', $userId, 'lastname']),
|
$this->getData(['user', $userId, 'lastname']),
|
||||||
template::checkbox('courseUserSelect' . $userId , true, '')
|
template::checkbox('courseUserSelect' . $userId , true, '', ['class' => 'checkboxSelect'])
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ class course extends common
|
|||||||
$userId,
|
$userId,
|
||||||
$this->getData(['user', $userId, 'firstname']),
|
$this->getData(['user', $userId, 'firstname']),
|
||||||
$this->getData(['user', $userId, 'lastname']),
|
$this->getData(['user', $userId, 'lastname']),
|
||||||
template::checkbox('courseUserSelect' . $userId , true, '')
|
template::checkbox('courseUserSelect' . $userId , true, '', ['class' => 'checkboxSelect'])
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,11 @@
|
|||||||
|
|
||||||
$(document).ready((function () {
|
$(document).ready((function () {
|
||||||
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
|
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
|
||||||
$("#courseUsersAddForm").submit();
|
saveCheckboxState();
|
||||||
|
$("#courseUsersFilterForm").submit();
|
||||||
|
|
||||||
});
|
});
|
||||||
$('#dataTables').DataTable({
|
var table = $('#dataTables').DataTable({
|
||||||
language: {
|
language: {
|
||||||
url: "core/vendor/datatables/french.json"
|
url: "core/vendor/datatables/french.json"
|
||||||
},
|
},
|
||||||
@ -28,4 +30,36 @@ $(document).ready((function () {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle checkbox state on DataTables draw event
|
||||||
|
table.on('draw', function () {
|
||||||
|
// Restore checkbox state from cookies or local storage
|
||||||
|
restoreCheckboxState();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Function to save checkbox state
|
||||||
|
function saveCheckboxState() {
|
||||||
|
var checkboxState = [];
|
||||||
|
$('.checkboxSelect').each(function () {
|
||||||
|
checkboxState.push({
|
||||||
|
'rowIndex': $(this).closest('tr').index(),
|
||||||
|
'checked': $(this).prop('checked')
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Use cookies or local storage to store checkbox state
|
||||||
|
localStorage.setItem('checkboxState', JSON.stringify(checkboxState));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to restore checkbox state
|
||||||
|
function restoreCheckboxState() {
|
||||||
|
var checkboxState = JSON.parse(localStorage.getItem('checkboxState')) || [];
|
||||||
|
checkboxState.forEach(function (item) {
|
||||||
|
var rowIndex = item.rowIndex;
|
||||||
|
var checked = item.checked;
|
||||||
|
// Update checkbox state based on stored information
|
||||||
|
$('#example tbody tr:eq(' + rowIndex + ') .checkboxSelect').prop('checked', checked);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}));
|
}));
|
@ -1,4 +1,4 @@
|
|||||||
<?php echo template::formOpen('courseUsersAddForm'); ?>
|
<?php echo template::formOpen('courseUsersFilterForm'); ?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col1">
|
<div class="col1">
|
||||||
<?php echo template::button('courseUserAddBack', [
|
<?php echo template::button('courseUserAddBack', [
|
||||||
|
Loading…
Reference in New Issue
Block a user