From 4ece10eb57b6a1e7b085cbb131394ff9facd5c5f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Apr 2021 17:56:17 +0200 Subject: [PATCH] Bug 28096: Fix table settings for API datatables wrapper Bug 25287 added the table settings to the API datatables wrapper but it does not handled correctly the hidden columns. Test plan: Go to Home > Administration > Table settings Administration > libraries Tick "Is hidden by default" for "library_address" Go to Home > Administration > Libraries Click Columns and check the "Address" column, it must be hidden Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index bdf4dcd067..16c4e89584 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -773,6 +773,15 @@ 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(); $(this).find('thead tr:eq(1) th').each( function (i) { -- 2.11.0