From b8ad8ad37c94fbf5dc54e8332c3998da4f38e97f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 16 Oct 2024 10:38:32 +0100 Subject: [PATCH] Bug 33736: Ensure datatable filter row takes visible into account We clone the header row, and then iterate it assuming the iterator index lines up with the column definition index of the datatables settings. However, if a column is hidden, this is not the case. Said column will not appear in the header row that's cloned and as such your iterator will no longer line up with the column settings index number of the settings array. Sponsored-by: PTFS Europe Ltd Signed-off-by: Esther Melander Signed-off-by: Paul Derscheid --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index bfa9514f7d9..0a2db6c1239 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -830,7 +830,13 @@ function _dt_on_visibility(add_filters, table_node, table_dt){ function _dt_add_filters(table_node, table_dt, filters_options = {}) { $(table_node).find('thead tr').clone().appendTo( $(table_node).find('thead') ); + let j = -1; $(table_node).find('thead tr:eq(1) th').each( function (i) { + j++ + var is_visible = table_dt.settings()[0].aoColumns[j].bVisible; + if ( !is_visible ) { j++ } + i = j; + var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable; $(this).removeClass('sorting').removeClass("sorting_asc").removeClass("sorting_desc"); $(this).data('th-id', i); -- 2.47.0