This commit is contained in:
2026-03-28 17:05:20 +00:00
parent 82c921d249
commit d94d1ad727
3 changed files with 43 additions and 20 deletions

View File

@@ -366,7 +366,7 @@ function changer_langue_connexion() {
* @param {string|jQuery} selector - Sélecteur du tableau (ex: '.tabliste' ou '#myTable')
* @param {object} options - Options personnalisées (langue, boutons, ordre, etc.)
*/
function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Rapport") {
function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Rapport", message = "") {
const codeLangue = $("#codeLangue").val() || 'fr_FR';
const translations = {
@@ -389,19 +389,29 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
$(selector).each(function() {
const $table = $(this);
// Colonnes marquées comme 'data-hidden'
const hiddenTargets = [];
$table.find('thead th').each((idx, th) => {
if ($(th).data('hidden')) hiddenTargets.push(idx);
});
// Configuration des boutons avec le titre dynamique
// Configuration des boutons avec Titre ET Message de haut de page
const exportButtons = [
{ extend: 'copy', title: titreDoc },
{ extend: 'csv', title: titreDoc },
{ extend: 'excel', title: titreDoc },
{ extend: 'pdf', title: titreDoc },
{ extend: 'print', title: titreDoc }
{
extend: 'excel',
title: titreDoc,
messageTop: message // Ajoute les infos en haut de l'Excel
},
{
extend: 'pdf',
title: titreDoc,
messageTop: message, // Ajoute les infos en haut du PDF
orientation: 'landscape'
},
{
extend: 'print',
title: titreDoc,
messageTop: message // Ajoute les infos sur l'impression
}
];
const instance = $table.DataTable($.extend(true, {
@@ -411,10 +421,9 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
language: translations[codeLangue] || translations.fr_FR,
columnDefs: [{ targets: hiddenTargets, visible: false }],
dom: 'Bfrtip',
buttons: exportButtons // Utilisation des boutons configurés
buttons: exportButtons
}, options));
// Ajustement après rendu
$table.on('init.dt', function () {
if (instance && instance.responsive) {
instance.columns.adjust();