Bonjour,

je cherche quelqu'un qui s'y connait bien avec DATATABLES pour me conseiller......

j'ai découvert DATATABLE qui me rend beaucoup de service (fixer header, fixer les colonnes, responsive, toggle de colonne, ......).

J'étais super content jusqu'au moment où je me suis aperçu que mes checkbox qui me permettaient de sélectionner mes mails (soit un par un - soit tous en même temps) ne fonctionnaient plus ou ne sélectionner que les mails de la page en cours (pas plusieurs pages)

J'ai donc décidé de passer par les options DATATABLES mais je n'y arrive pas.

J'aimerai avoir la possibilité de sélectionner via des checkbox soit un par un des contacts (si coché alors récupère le mail du contact) - soit tous mes contacts (récupère tous les mails des contacts) via une checkbox (selectAll ou unselectAll).
Sachant que mes données sont issues d'un traitement PHP - SQL - BDD (côté serveur).

j'ai beaucoup lu et cherché mais je n'y arrive pas. J'ai vu que des examples avec AJAX.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="fr">
 <head>


  <!-- JS LIBRAIRIES  -->
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

  <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
		
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>

	
  <!--  --------------- DATATABLES  -------------------------------  -->

  <!--  JS DATATABLES  -->
  <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
  <script src="https://cdn.datatables.net/fixedcolumns/3.2.6/js/dataTables.fixedColumns.min.js"></script>
		

  <!--  CSS DATATABLES  -->
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
  <link rel="stylesheet" href="https://cdn.datatables.net/fixedcolumns/3.2.6/css/fixedColumns.dataTables.min.css">


  <!--  DATATABLES CHECKBOX  -->
  <script src="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/js/dataTables.checkboxes.min.js"></script>
  <script src="https://cdn.datatables.net/v/dt/dt-1.10.16/sl-1.2.5/datatables.min.js"></script>
  <link type="text/css" rel="stylesheet" href="https://gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/css/dataTables.checkboxes.css"></link>
  <link type="text/css" rel="stylesheet" href="https://cdn.datatables.net/v/dt/dt-1.10.16/sl-1.2.5/datatables.min.css"></link>
  <link type="text/css" href="//gyrocode.github.io/jquery-datatables-checkboxes/1.2.11/css/dataTables.checkboxes.css" rel="stylesheet" />
		

      
 </head>

 <body>

  <form action="../CONTROLLER/Send_MailMulti.php" method="POST">

   <h1> RESULTAT DE LA RECHERCHE MULTICRITERES </h1>

   <div class="content" id="content">

   <?php if (empty($contacts)): ?>
								
    <p> Il n'y a aucun contact à afficher </p> 
    <a href="../View/Form_SearchMulti.php"> Revenir au formulaire de recherche </a>

   <?php else: ?>

    <?php if($contacts === false): ?>

     <p> Une erreur est survenue </p>

   <?php else: ?>

    <!--  ----------------------------------- TABLE ----------------------------------------   -->

    <table id="example" class="stripe row-border order-column display nowrap" style="width:100%;border: 1px solid black;" >
								

     <thead>

      <tr>
       <th></th>
       <!--<th><input id="selectAll" type="checkbox" /></th>-->
       <th>NOM</th>
       <th>PRENOM</th>
       <th>MAIL</th>

       <th>MODIFIER</th>
       <th>PDF</th>
      </tr>

  </thead>


  <tbody>

   <?php 

											
    $i=0;
    foreach ($contacts as $contact)	{

     echo '<tr class="ligne'.($i % 2).'">';
      echo '<td>  </td>';
      //echo '<td> <input type="checkbox" class="select_checkbox" name="mails_checked[]"  value="'.Secur::screen($contact->getEmail()).'"/> </td>';
      echo( "<td>".Secur::screen($contact->getNom())."</td>" );
      echo( "<td>".Secur::screen($contact->getPrenom())."</td>" );
      echo( "<td>".Secur::screen($contact->getEmail())."</td>" );

      echo '<td> <a href="../VIEW/Form_Update_Registration.php?id='.Secur::screen($contact->getId()).' "> MODIFIER </a>  </td>';  
      echo '<td> <a href="../MODEL/Create_PDF_Player.php?id='.Secur::screen($contact->getId()).' "> FICHE </a>  </td>';  
      echo( "</tr>" );

      $i++; 
   }
  ?>    

  </tbody>                
														                         
 </table>


 <?php endif; ?>		

 <?php endif; ?>	

</div>

 <div class="footer">		

  <button class="btn_footer" type="text" id='btn_mail'> MAIL </button>

 </div>

 </form> <!-- FIN DU 1ER FORMULAIRE -->




 <script type="text/javascript">
           
  $(document).ready(function() {

   var table = $('#example').DataTable({
    scrollY:        "380px",  /* hauteur du tableau */
    scrollX:        true,
    scrollCollapse: true,
    paging:         true,

   /* FIXE LES COLONNES DROITES ET GAUCHES D'UN TABLEAU  */ 
   fixedColumns:   {
    leftColumns: 3,
    rightColumns: 2
   }

   //...........................

  });
 }); 

 </script>	

 </body>
</html>

Send_MailMulti.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
// RETOURNE LE MAIL DES CONTACTS ISSUS DES CHECKBOX SELECTIONNES  (array =  $mails_destinataires)
var_dump($_POST);
die;
1. Créer une checkbox qui me permettent de tout sélectionner ou désélectionner sur plusieurs pages
2. Récupérer les adresses mails des contacts si checkbox cochés pour les soumettre au fichier Send_MailMulti.php ????