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.
这个提交包含在:
父节点
9a5f825d10
当前提交
c28aaf4665
共有 1 个文件被更改,包括 15 次插入 和 1 次删除
|
|
@ -83,6 +83,10 @@ $('.bandtable').DataTable({
|
||||||
],
|
],
|
||||||
"drawCallback": function() {
|
"drawCallback": function() {
|
||||||
updateStatistics();
|
updateStatistics();
|
||||||
|
},
|
||||||
|
"initComplete": function() {
|
||||||
|
// Ensure statistics are updated when table is fully initialized
|
||||||
|
updateStatistics();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -138,6 +142,13 @@ $('#showAll').addClass('active');
|
||||||
// Update statistics
|
// Update statistics
|
||||||
function updateStatistics() {
|
function updateStatistics() {
|
||||||
var activeBands = $('.band-checkbox-cell input[type="checkbox"]:checked').length;
|
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);
|
$('#activeBandsCount').text(activeBands);
|
||||||
|
|
||||||
// Update visible rows count
|
// Update visible rows count
|
||||||
|
|
@ -148,7 +159,10 @@ function updateStatistics() {
|
||||||
|
|
||||||
// Update statistics on page load
|
// Update statistics on page load
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
updateStatistics();
|
// Wait for table to be fully rendered before calculating stats
|
||||||
|
setTimeout(function() {
|
||||||
|
updateStatistics();
|
||||||
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update statistics when band status changes
|
// Update statistics when band status changes
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用