This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
<?= $this->extend('layout/main_layout') ?>
|
||||
<?= $this->section('styles') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/dataTables.bootstrap5.min.css">
|
||||
<?= $this->endSection() ?>
|
||||
<?= $this->section('content') ?>
|
||||
|
||||
<style>
|
||||
@@ -131,10 +135,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="9" class="text-center">No students found in this class.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -154,17 +154,33 @@
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('scripts') ?>
|
||||
<script src="https://cdn.datatables.net/1.13.10/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.10/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
if (!(window.jQuery && jQuery.fn && jQuery.fn.DataTable)) {
|
||||
return;
|
||||
}
|
||||
<?php if (!empty($classes)): ?>
|
||||
<?php foreach ($classes as $index => $class): ?>
|
||||
$('#classTable<?= $index ?>').DataTable({
|
||||
const table<?= $index ?> = $('#classTable<?= $index ?>');
|
||||
const expectedColumns<?= $index ?> = table<?= $index ?>.find('thead th').length;
|
||||
const hasInvalidRows<?= $index ?> = table<?= $index ?>.find('tbody tr').toArray().some(function(row) {
|
||||
return $(row).children('td, th').length !== expectedColumns<?= $index ?>;
|
||||
});
|
||||
if (hasInvalidRows<?= $index ?>) {
|
||||
return;
|
||||
}
|
||||
table<?= $index ?>.DataTable({
|
||||
// Keep columns visible and avoid squeezing
|
||||
responsive: false, // prevent column hiding that can make table look small
|
||||
autoWidth: true, // let DT calculate widths, we'll still force 100% via CSS
|
||||
scrollX: true, // allow horizontal scroll when needed
|
||||
pageLength: 25,
|
||||
lengthChange: false,
|
||||
language: {
|
||||
emptyTable: 'No students found in this class.'
|
||||
},
|
||||
columnDefs: [
|
||||
{ targets: '_all', className: 'text-nowrap' } // avoid wrapping labels
|
||||
]
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?= $this->extend('layout/main_layout') ?>
|
||||
|
||||
<?= $this->section('styles') ?>
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/jquery.dataTables.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.10/css/dataTables.bootstrap5.min.css">
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="container-xxl py-5">
|
||||
<div class="container">
|
||||
@@ -282,6 +287,8 @@
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('scripts') ?>
|
||||
<script src="https://cdn.datatables.net/1.13.10/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.10/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded",()=>{
|
||||
const form=document.getElementById("attendanceForm");
|
||||
@@ -316,16 +323,34 @@ document.addEventListener("DOMContentLoaded",()=>{
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
$('#teachersTable').DataTable({
|
||||
pageLength:100,
|
||||
order:[],
|
||||
columnDefs:[{targets:[0,3,4,5,6],className:'text-center'}]
|
||||
});
|
||||
$('#studentsTable').DataTable({
|
||||
pageLength:100,
|
||||
order:[],
|
||||
columnDefs:[{targets:[0,4,5,6,7],className:'text-center'}]
|
||||
});
|
||||
if (!(window.jQuery && jQuery.fn && jQuery.fn.DataTable)) {
|
||||
return;
|
||||
}
|
||||
|
||||
function hasValidRows($table) {
|
||||
const expectedColumns = $table.find('thead th').length;
|
||||
return !$table.find('tbody tr').toArray().some(function(row) {
|
||||
return $(row).children('td, th').length !== expectedColumns;
|
||||
});
|
||||
}
|
||||
|
||||
const $teachersTable = $('#teachersTable');
|
||||
if ($teachersTable.length && hasValidRows($teachersTable)) {
|
||||
$teachersTable.DataTable({
|
||||
pageLength:100,
|
||||
order:[],
|
||||
columnDefs:[{targets:[0,3,4,5,6],className:'text-center'}]
|
||||
});
|
||||
}
|
||||
|
||||
const $studentsTable = $('#studentsTable');
|
||||
if ($studentsTable.length && hasValidRows($studentsTable)) {
|
||||
$studentsTable.DataTable({
|
||||
pageLength:100,
|
||||
order:[],
|
||||
columnDefs:[{targets:[0,4,5,6,7],className:'text-center'}]
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
Reference in New Issue
Block a user