fdgh
This commit is contained in:
parent
f47d1f9c73
commit
4b54b457de
|
|
@ -91659,58 +91659,24 @@ function loadMessageSection(section) {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Données') {
|
||||
if ($(selector).length === 0) return;
|
||||
|
||||
// Détection automatique : la barre de recherche personnalisée existe-t-elle ?
|
||||
var hasGlobalSearch = $('#globalSearch').length > 0;
|
||||
|
||||
if ($.fn.DataTable.isDataTable(selector)) {
|
||||
$(selector).DataTable().destroy();
|
||||
}
|
||||
|
||||
return $(selector).DataTable({
|
||||
// MODIFICATION : On utilise une seule ligne (div) pour les boutons et la recherche
|
||||
"dom": '<"d-flex align-items-center justify-content-between p-3 border-bottom"Bf>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>',
|
||||
"buttons": [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
text: '<i class="fas fa-file-excel me-2"></i>Excel',
|
||||
className: 'btn btn-success btn-sm fw-bold border-0 shadow-sm px-3'
|
||||
},
|
||||
{
|
||||
extend: 'pdfHtml5',
|
||||
text: '<i class="fas fa-file-pdf me-2"></i>PDF',
|
||||
className: 'btn btn-danger btn-sm fw-bold border-0 shadow-sm px-3 ms-2', // Ajout d'une marge à gauche du bouton PDF
|
||||
title: pageTitle,
|
||||
orientation: 'landscape',
|
||||
pageSize: 'A4'
|
||||
}
|
||||
],
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json",
|
||||
"search": "Rechercher : ",
|
||||
"searchPlaceholder": "Filtrer..."
|
||||
},
|
||||
"pageLength": 10,
|
||||
"autoWidth": false,
|
||||
"drawCallback": function() {
|
||||
// Style de la barre de recherche pour qu'elle ne soit pas trop collée
|
||||
$('.dataTables_filter input').addClass('form-control form-control-sm d-inline-block ms-2 rounded-pill border-2 shadow-none').css('width', '200px');
|
||||
$('.dataTables_paginate .paginate_button').addClass('btn btn-xs mx-1');
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
// Configuration du DOM :
|
||||
// Si hasGlobalSearch est vrai, on retire 'f' (recherche native)
|
||||
var domStructure = hasGlobalSearch
|
||||
? '<"d-flex align-items-center justify-content-start p-3 border-bottom"B>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>'
|
||||
: '<"d-flex align-items-center justify-content-between p-3 border-bottom"Bf>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>';
|
||||
|
||||
function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Données') {
|
||||
if ($(selector).length === 0) return;
|
||||
|
||||
if ($.fn.DataTable.isDataTable(selector)) {
|
||||
$(selector).DataTable().destroy();
|
||||
}
|
||||
|
||||
return $(selector).DataTable({
|
||||
// MODIFICATION : On retire 'f' pour masquer la recherche native
|
||||
"dom": '<"d-flex align-items-center justify-content-start p-3 border-bottom"B>t<"d-flex justify-content-between align-items-center p-3 bg-light"ip>',
|
||||
var table = $(selector).DataTable({
|
||||
"dom": domStructure,
|
||||
"buttons": [
|
||||
{
|
||||
extend: 'excelHtml5',
|
||||
|
|
@ -91727,12 +91693,27 @@ function initSmartTable(selector = '.datatable-inter', pageTitle = 'Export Donn
|
|||
}
|
||||
],
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json"
|
||||
"url": "//cdn.datatables.net/plug-ins/1.13.6/i18n/fr-FR.json",
|
||||
"search": "Rechercher : ",
|
||||
"searchPlaceholder": "Filtrer..."
|
||||
},
|
||||
"pageLength": 10,
|
||||
"autoWidth": false,
|
||||
"drawCallback": function() {
|
||||
// Style uniquement si la recherche native est affichée
|
||||
if (!hasGlobalSearch) {
|
||||
$('.dataTables_filter input').addClass('form-control form-control-sm d-inline-block ms-2 rounded-pill border-2 shadow-none').css('width', '200px');
|
||||
}
|
||||
$('.dataTables_paginate .paginate_button').addClass('btn btn-xs mx-1');
|
||||
}
|
||||
});
|
||||
|
||||
// LIAISON AUTOMATIQUE : Si globalSearch existe, on branche l'événement tout de suite
|
||||
if (hasGlobalSearch) {
|
||||
$('#globalSearch').off('keyup').on('keyup', function() {
|
||||
table.search(this.value).draw();
|
||||
});
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
|
@ -70,17 +70,10 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// On utilise l'événement natif du navigateur pour être sûr que TOUS les scripts (dont jQuery) sont chargés
|
||||
window.addEventListener('load', function() {
|
||||
// Maintenant jQuery ($) est forcément défini
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
// Initialisation
|
||||
var tableBons = initSmartTable('.table', 'Gestion des Bons');
|
||||
|
||||
// Liaison du champ de recherche personnalisé
|
||||
$('#globalSearch').on('keyup', function() {
|
||||
tableBons.search(this.value).draw();
|
||||
});
|
||||
// La fonction détecte seule #globalSearch et lie la recherche !
|
||||
initSmartTable('.table', 'Gestion des Bons');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -92,17 +92,10 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// On utilise l'événement natif du navigateur pour être sûr que TOUS les scripts (dont jQuery) sont chargés
|
||||
window.addEventListener('load', function() {
|
||||
// Maintenant jQuery ($) est forcément défini
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
// Initialisation
|
||||
var tableLiens = initSmartTable('.table', 'Gestion des Liens de Parenté');
|
||||
|
||||
// Liaison du champ de recherche personnalisé
|
||||
$('#globalSearch').on('keyup', function() {
|
||||
tableLiens.search(this.value).draw();
|
||||
});
|
||||
// La fonction détecte seule #globalSearch et lie la recherche !
|
||||
initSmartTable('.table', 'Gestion des Liens de Parenté');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user