From 2b8d9a6e937a4cc5e43926bb6a21780258112b1e 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. --- 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 5f5d81a34f5..1d8bab6d336 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -822,7 +822,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