mouhsineelachbi

data table

Jul 23rd, 2021
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function tableMembres() {
  2.  
  3.     $('#membre-table').DataTable({
  4.         searching: true,
  5.         ordering: true,
  6.         processing: false,
  7.         "paging": true,
  8.         "language": {
  9.             "buttons": {
  10.                 "copyKeys": "Appuyer sur ctrl ou u2318 + C pour copier les données du tableau dans votre presse-papier.",
  11.                 "collection": "Collection",
  12.                 "colvis": "Visibilité colonnes",
  13.                 "colvisRestore": "Rétablir visibilité",
  14.                 "copy": "Copier",
  15.                 "copySuccess": {
  16.                     "1": "1 ligne copiée dans le presse-papier",
  17.                     "_": "%d lignes copiées dans le presse-papier"
  18.                 },
  19.                 "copyTitle": "Copier dans le presse-papier",
  20.                 "csv": "CSV",
  21.                 "excel": "Excel",
  22.                 "pageLength": {
  23.                     "-1": "Afficher toutes les lignes",
  24.                     "1": "Afficher 1 ligne",
  25.                     "_": "Afficher %d lignes"
  26.                 },
  27.                 "pdf": "PDF",
  28.                 "print": "Imprimer"
  29.             },
  30.             "lengthMenu": "Afficher les enregistrements _MENU_ par page",
  31.             "zeroRecords": "Aucun membre disponible avec cet indice",
  32.             "info": "Affichage de la page _PAGE_ de _PAGES_",
  33.             "infoEmpty": "Aucun enregistrement disponible",
  34.             "infoFiltered": "(filtré à partir du nombre total d'enregistrements _MAX_ )",
  35.             "sSearch": "Rechercher :",
  36.             "paginate": {
  37.                 "first":      "Premier",
  38.                 "last":       "Dernier",
  39.                 "next":       "Suivant",
  40.                 "previous":   "Précédent"
  41.             },
  42.             "loadingRecords": "Chargement...",
  43.             "processing":     "Traitement..."
  44.         },
  45.         "search": {
  46.             "caseInsensitive": true
  47.         },
  48.         dom: 'Bfrtip',
  49.         buttons: [
  50.             {
  51.                 extend: 'colvis',
  52.                 collectionLayout: 'fixed two-column',
  53.                 text: '<i class="fas fa-columns"></i>',
  54.                 titleAttr: 'Visibilité de la colonne'
  55.                 //className: 'classes here'
  56.             },
  57.             {
  58.                 extend: 'excelHtml5',
  59.                 exportOptions: { columns: [ 1, 2, 3, 4, 5, 6, 7 ]},
  60.                 text: '<i class="far fa-file-excel"></i>',
  61.                 title: 'Liste des membres',
  62.                 titleAttr: 'Exportation Excel'
  63.             },
  64.             {
  65.                 extend: 'pdfHtml5',
  66.                 text: '<i class="far fa-file-pdf"></i>',
  67.                 titleAttr: 'Exportation PDF',
  68.                 download: 'open',
  69.                 messageTop: 'PDF créé par la C.A.M.A.R',
  70.                 title: 'Liste des membres',
  71.                 footer: true,
  72.                 //orientation: 'landscape',
  73.                 pageSize: 'A4',
  74.                 exportOptions: {
  75.                     columns: ':visible',
  76.                     search: 'applied',
  77.                     order: 'applied'
  78.                 },
  79.                 exportOptions: { columns: [ 1, 2, 3, 4, 5, 6, 7, 8 ]},
  80.                 customize: function (doc) {
  81.                     doc.content.splice( 1, 0, {
  82.                         margin: [ 0, 0, 0, 22 ],
  83.                         width: 130,
  84.                         height: 130,
  85.                         opacity: 0.9,
  86.                         alignment: 'center',
  87.                         image: 'data:image/png;base64,'+ image_logo // Variable image base64
  88.                     });
  89.                     doc.defaultStyle.alignment = 'center';
  90.                 }
  91.             },
  92.             {
  93.                 extend: 'print',
  94.                 exportOptions: { columns: [ 1, 2, 3, 4, 5, 6, 7, 8 ]},
  95.                 text: '<i class="fas fa-print"></i>',
  96.                 titleAttr: 'Impression',
  97.                 alignment: 'center'
  98.             },
  99.             {
  100.                 extend: 'copyHtml5',
  101.                 exportOptions: { columns: [ 1, 2, 3, 4, 5, 6, 7, 8 ]},
  102.                 copyTitle: 'Ajouté au presse-papiers',
  103.                 text: '<i class="far fa-copy"></i>',
  104.                 titleAttr: 'Copier'
  105.             }
  106.         ],
  107.         columnDefs: [
  108.             { targets: -1, className: 'dt-body-center' },
  109.             { orderable: false, targets: 0 },
  110.             { orderable: false, targets: 7 },
  111.             { orderable: false, targets: 9 },
  112.             { targets: 1, className: 'noVis' }
  113.         ],
  114.         order: [[1, 'asc']],
  115.         responsive: true,
  116.         "pagingType": "simple_numbers",
  117.         "pageLength": 5,
  118.         "lengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "Tout"]]
  119.     });
  120.  
  121.     $('#membre-table').DataTable().column(2).visible(false);
  122.     $('#membre-table').DataTable().column(7).visible(false);
  123.  
  124. }
Add Comment
Please, Sign In to add comment