Maj DataTable

This commit is contained in:
2025-12-25 13:08:19 +00:00
parent 730b94ebe4
commit a6ae4e7efe
3 changed files with 88 additions and 80 deletions

View File

@@ -376,67 +376,62 @@ function connexion_cookie()
// Applique la librairie DataBase sur les tableaux
function appliquerDataTable() {
const $table = $('.tabliste');
const codeLangue = $("#codeLangue").val();
// Dictionnaire des traductions
const translations = {
en_US: {
lengthMenu: "Display _MENU_ records per page",
zeroRecords: "Nothing found - sorry",
info: "Showing page _PAGE_ of _PAGES_",
infoEmpty: "No records available",
search: "Search:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
infoFiltered: "(filtered from _MAX_ total records)"
},
fr_FR: {
lengthMenu: "Affiche _MENU_ par page",
zeroRecords: "Désolé - Aucune donnée trouvée",
info: "_PAGE_ sur _PAGES_ pages",
infoEmpty: "Pas d'enregistrement",
search: "Recherche:",
paginate: {
next: "►",
previous: "◄",
first: "|◄",
last: "►|"
},
paginate: { next: "►", previous: "◄", first: "|◄", last: "►|" },
infoFiltered: "(filtré de _MAX_ total enregistrements)"
},
en_US: {
lengthMenu: "Display _MENU_ records per page",
zeroRecords: "Nothing found - sorry",
info: "Showing page _PAGE_ of _PAGES_",
infoEmpty: "No records available",
search: "Search:",
paginate: { next: "►", previous: "◄", first: "|◄", last: "►|" },
infoFiltered: "(filtered from _MAX_ total records)"
}
};
// Options DataTable
const options = {
destroy: true,
responsive: true,
order: [[0, "desc"]],
lengthMenu: [50, 100, 150],
pagingType: "full_numbers",
autoWidth: false,
language: translations[codeLangue] || translations.fr_FR
};
$('.tabliste').each(function() {
const $table = $(this);
// Détecter les colonnes avec data-hidden="true"
const hiddenTargets = [];
$table.find('thead th').each(function(index) {
if ($(this).data('hidden')) {
hiddenTargets.push(index);
}
});
const options = {
destroy: true,
responsive: true,
order: [[0, "desc"]],
lengthMenu: [50, 100, 150],
pagingType: "full_numbers",
autoWidth: false,
language: translations[codeLangue] || translations.fr_FR,
columnDefs: [
{ targets: hiddenTargets, visible: false, searchable: true }
]
};
try {
// Initialisation
const instance = $table.DataTable(options);
// Correction d'alignement après le rendu
setTimeout(() => {
instance.columns.adjust().responsive.recalc();
}, 100);
} catch (err) {
console.error("Erreur lors de l'application du DataTable :", err);
return false;
}
});
}
function raffraichier_gabarit()
{