Correction des erreurs dans console
This commit is contained in:
@@ -52,7 +52,12 @@ function connexion_cookie() {
|
||||
|
||||
$(function() {
|
||||
// 1. Initialisation des composants au chargement de la page
|
||||
appliquerDataTable();
|
||||
appliquerDataTable('#claimsTable', {
|
||||
order: [[1, "asc"]], // tri sur la 2e colonne
|
||||
buttons: ['excel', 'pdf'], // seulement export Excel et PDF
|
||||
pageLength: 25 // 25 lignes par page
|
||||
});
|
||||
|
||||
|
||||
// 2. Lancement du cycle de rafraîchissement automatique
|
||||
const vueActuelle = $("#vue").val();
|
||||
@@ -83,7 +88,7 @@ function raffraichier_gabarit() {
|
||||
success: function(data) {
|
||||
// Injection du nouveau contenu
|
||||
debugger;
|
||||
|
||||
|
||||
$("#div_ajaxgabarit").html(data);
|
||||
|
||||
const codeSociete = $("#codeSociete").val();
|
||||
@@ -325,10 +330,14 @@ function changer_langue_connexion() {
|
||||
|
||||
/**
|
||||
* CONFIGURATION DATATABLES
|
||||
* Initialise les tableaux avec exports, filtres et traductions.
|
||||
* Initialise un tableau DataTable avec options génériques.
|
||||
*
|
||||
* @param {string|jQuery} selector - Sélecteur du tableau (ex: '.tabliste' ou '#myTable')
|
||||
* @param {object} options - Options personnalisées (langue, boutons, ordre, etc.)
|
||||
*/
|
||||
function appliquerDataTable() {
|
||||
function appliquerDataTable(selector = '.tabliste', options = {}) {
|
||||
const codeLangue = $("#codeLangue").val() || 'fr_FR';
|
||||
|
||||
const translations = {
|
||||
fr_FR: {
|
||||
lengthMenu: "Affiche _MENU_ par page",
|
||||
@@ -346,15 +355,16 @@ function appliquerDataTable() {
|
||||
}
|
||||
};
|
||||
|
||||
$('.tabliste').each(function() {
|
||||
$(selector).each(function() {
|
||||
const $table = $(this);
|
||||
// On récupère les colonnes marquées comme 'data-hidden'
|
||||
|
||||
// Colonnes marquées comme 'data-hidden'
|
||||
const hiddenTargets = [];
|
||||
$table.find('thead th').each((idx, th) => {
|
||||
if ($(th).data('hidden')) hiddenTargets.push(idx);
|
||||
});
|
||||
|
||||
const instance = $table.DataTable({
|
||||
const instance = $table.DataTable($.extend(true, {
|
||||
destroy: true,
|
||||
responsive: true,
|
||||
order: [[0, "desc"]],
|
||||
@@ -362,10 +372,15 @@ function appliquerDataTable() {
|
||||
columnDefs: [{ targets: hiddenTargets, visible: false }],
|
||||
dom: 'Bfrtip',
|
||||
buttons: ['copy', 'csv', 'excel', 'pdf', 'print']
|
||||
});
|
||||
}, options));
|
||||
|
||||
// Ajustement forcé après rendu pour éviter les problèmes de colonnes mal alignées
|
||||
setTimeout(() => instance.columns.adjust().responsive.recalc(), 100);
|
||||
// Ajustement après rendu
|
||||
$table.on('init.dt', function () {
|
||||
if (instance && instance.responsive) {
|
||||
instance.columns.adjust();
|
||||
instance.responsive.recalc();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user