diff --git a/app/static/js/table_recap.js b/app/static/js/table_recap.js index 8d52644124..805153fdab 100644 --- a/app/static/js/table_recap.js +++ b/app/static/js/table_recap.js @@ -9,6 +9,22 @@ $(function () { } else { hidden_colums = hidden_colums.concat(["recorded_code"]); } + // Etat (tri des colonnes) de la table: + + const url = new URL(document.URL); + const formsemestre_id = url.searchParams.get("formsemestre_id"); + const order_info_key = JSON.stringify([url.pathname, formsemestre_id]); + let order_info; + if (formsemestre_id) { + const x = localStorage.getItem(order_info_key); + if (x) { + try { + order_info = JSON.parse(x); + } catch (error) { + console.error(error); + } + } + } // Les boutons dépendent du mode BUT ou classique: let buttons = [ { @@ -169,7 +185,15 @@ $(function () { autoClose: true, buttons: buttons, }, - ] + ], + "drawCallback": function (settings) { + // permet de conserver l'ordre de tri des colonnes + let order_info = JSON.stringify($('table.table_recap').DataTable().order()); + if (formsemestre_id) { + localStorage.setItem(order_info_key, order_info); + } + }, + "order": order_info, } );