Improve band statistics update logic

Ensures statistics are updated both on DataTable initialization and after rendering. Adds a fallback selector for counting active bands and delays initial statistics update to wait for table rendering.
这个提交包含在:
Peter Goodhall 2025-08-09 23:17:53 +01:00
父节点 9a5f825d10
当前提交 c28aaf4665

查看文件

@ -83,6 +83,10 @@ $('.bandtable').DataTable({
],
"drawCallback": function() {
updateStatistics();
},
"initComplete": function() {
// Ensure statistics are updated when table is fully initialized
updateStatistics();
}
});
@ -138,6 +142,13 @@ $('#showAll').addClass('active');
// Update statistics
function updateStatistics() {
var activeBands = $('.band-checkbox-cell input[type="checkbox"]:checked').length;
// Fallback: if the class-based selector doesn't work, try alternative selectors
if (activeBands === 0) {
// Try finding by column position (first column checkboxes)
activeBands = $('.bandtable tbody tr td:first-child input[type="checkbox"]:checked').length;
}
$('#activeBandsCount').text(activeBands);
// Update visible rows count
@ -148,7 +159,10 @@ function updateStatistics() {
// Update statistics on page load
$(document).ready(function() {
updateStatistics();
// Wait for table to be fully rendered before calculating stats
setTimeout(function() {
updateStatistics();
}, 500);
});
// Update statistics when band status changes