From cf320089d1062c9f0459a89f7ac68dc92b26f23b Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 1 Apr 2022 10:16:09 +0200 Subject: [PATCH] Bug 30406: Add column filters before hiding columns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code that adds column filters works only on visible columns, so we should hide columns after filters are created Test plan: 1. Apply patch 2. Go to Tables settings. Hide city_state for the cities table. 3. Create some cities and go to the cities page 4. Verify that filtering works as expected. 5. Make the city_state column appear. Verify that filtering on this column works too Signed-off-by: Séverine QUEUNE --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index d5f100555b..60e5214375 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -793,14 +793,6 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { var table = $(this).dataTable(settings); - table.DataTable().on("column-visibility.dt", function(){ - if( typeof columnsInit == 'function' ){ - // This function can be created separately and used to trigger - // an event after the DataTable has loaded AND column visibility - // has been updated according to the table's configuration - columnsInit(); - } - }).columns( hidden_ids ).visible( false ); if ( add_filters ) { var table_dt = table.DataTable(); @@ -855,6 +847,15 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { } ); } + table.DataTable().on("column-visibility.dt", function(){ + if( typeof columnsInit == 'function' ){ + // This function can be created separately and used to trigger + // an event after the DataTable has loaded AND column visibility + // has been updated according to the table's configuration + columnsInit(); + } + }).columns( hidden_ids ).visible( false ); + return table; }; -- 2.30.2