dsaer
This commit is contained in:
parent
063e3b072d
commit
aba92b07f2
|
|
@ -367,10 +367,8 @@ function changer_langue_connexion() {
|
|||
* @param {string} message - Informations de police/contexte sous le titre (messageTop)
|
||||
*/
|
||||
function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Rapport", message = "") {
|
||||
// 1. Détection de la langue via un champ caché dans votre header
|
||||
const codeLangue = $("#codeLangue").val() || 'fr_FR';
|
||||
|
||||
// 2. Dictionnaire de traduction
|
||||
const translations = {
|
||||
fr_FR: {
|
||||
lengthMenu: "Affiche _MENU_ par page",
|
||||
|
|
@ -379,10 +377,7 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
|
|||
infoEmpty: "Aucun enregistrement disponible",
|
||||
infoFiltered: "(filtré de _MAX_ total)",
|
||||
search: "Recherche rapide :",
|
||||
paginate: {
|
||||
next: "Suivant ►",
|
||||
previous: "◄ Précédent"
|
||||
}
|
||||
paginate: { next: "Suivant ►", previous: "◄ Précédent" }
|
||||
},
|
||||
en_US: {
|
||||
lengthMenu: "Display _MENU_ records",
|
||||
|
|
@ -391,63 +386,53 @@ function appliquerDataTable(selector = '.tabliste', options = {}, titreDoc = "Ra
|
|||
infoEmpty: "No records available",
|
||||
infoFiltered: "(filtered from _MAX_ total)",
|
||||
search: "Quick Search:",
|
||||
paginate: {
|
||||
next: "Next ►",
|
||||
previous: "◄ Previous"
|
||||
}
|
||||
paginate: { next: "Next ►", previous: "◄ Previous" }
|
||||
}
|
||||
};
|
||||
|
||||
$(selector).each(function() {
|
||||
const $table = $(this);
|
||||
|
||||
// 3. Gestion automatique des colonnes masquées (via l'attribut data-hidden="true" sur le TH)
|
||||
const hiddenTargets = [];
|
||||
$table.find('thead th').each((idx, th) => {
|
||||
if ($(th).data('hidden')) {
|
||||
hiddenTargets.push(idx);
|
||||
}
|
||||
if ($(th).data('hidden')) hiddenTargets.push(idx);
|
||||
});
|
||||
|
||||
// 4. Configuration des boutons d'export avec Titre et Message Contextuel
|
||||
const exportConfig = {
|
||||
title: titreDoc,
|
||||
messageTop: message,
|
||||
exportOptions: {
|
||||
columns: ':visible' // Exporte uniquement ce qui est affiché à l'écran
|
||||
}
|
||||
exportOptions: { columns: ':visible' }
|
||||
};
|
||||
|
||||
// 5. Initialisation de l'instance DataTable
|
||||
// --- CORRECTION ICI ---
|
||||
// On définit les boutons par défaut uniquement SI aucun bouton n'est fourni dans 'options'
|
||||
const defaultButtons = [
|
||||
$.extend(true, {}, exportConfig, { extend: 'copy', className: 'btn btn-sm btn-light' }),
|
||||
$.extend(true, {}, exportConfig, { extend: 'excel', className: 'btn btn-sm btn-success' }),
|
||||
$.extend(true, {}, exportConfig, {
|
||||
extend: 'pdf',
|
||||
className: 'btn btn-sm btn-danger',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}),
|
||||
$.extend(true, {}, exportConfig, { extend: 'print', className: 'btn btn-sm btn-dark' })
|
||||
];
|
||||
|
||||
// On vérifie si l'utilisateur a passé ses propres boutons
|
||||
const finalButtons = (options && options.buttons) ? options.buttons : defaultButtons;
|
||||
|
||||
const instance = $table.DataTable($.extend(true, {
|
||||
destroy: true, // Permet de réinitialiser la table si elle existe déjà
|
||||
responsive: true, // Adaptation mobile
|
||||
pageLength: 25, // Nombre de lignes par défaut
|
||||
order: [[0, "desc"]], // Tri par défaut sur la 1ère colonne
|
||||
dom: 'Bfrtip', // Positionnement des éléments (Buttons, filter, processing, table, info, pagination)
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
pageLength: 25,
|
||||
order: [[0, "desc"]],
|
||||
dom: 'Bfrtip',
|
||||
language: translations[codeLangue] || translations.fr_FR,
|
||||
columnDefs: [
|
||||
{ targets: hiddenTargets, visible: false } // Masque les colonnes techniques
|
||||
],
|
||||
// Activation du Header et Footer collants (Nécessite l'extension FixedHeader)
|
||||
fixedHeader: {
|
||||
header: true,
|
||||
footer: true
|
||||
},
|
||||
buttons: [
|
||||
$.extend(true, {}, exportConfig, { extend: 'copy', className: 'btn btn-sm btn-light' }),
|
||||
$.extend(true, {}, exportConfig, { extend: 'excel', className: 'btn btn-sm btn-success' }),
|
||||
$.extend(true, {}, exportConfig, {
|
||||
extend: 'pdf',
|
||||
className: 'btn btn-sm btn-danger',
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}),
|
||||
$.extend(true, {}, exportConfig, { extend: 'print', className: 'btn btn-sm btn-dark' })
|
||||
]
|
||||
columnDefs: [{ targets: hiddenTargets, visible: false }],
|
||||
fixedHeader: { header: true, footer: true },
|
||||
buttons: finalButtons // On utilise la liste filtrée
|
||||
}, options));
|
||||
|
||||
// 6. Recalcul de la largeur des colonnes après le rendu initial
|
||||
$table.on('init.dt', function () {
|
||||
if (instance && instance.responsive) {
|
||||
instance.columns.adjust();
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ $photoAssureCrypte = $_SESSION['photoAssureCrypte'];
|
|||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||
|
||||
<!-- Application Scripts -->
|
||||
<script src="/Js/fonctions.js?ver=2026.03.29.01"></script>
|
||||
<script src="/Js/fonctions.js?ver=2026.03.29.02"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
raffraichier_gabarit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user