Bonjour, j'ai un petit soucis sur mon tableau je m'explique: je voudrais un tableau avec une checkbox sur chaque ligne mais dès que j'inserré cette colonne a mon tableau:
sa me rajoute en même une colonne supplémentaire vide qui me fausse tout mon tableau avec cette colonne
Code : Sélectionner tout - Visualiser dans une fenêtre à part <th><input type="checkbox" id="bulkDelete"/><button id="deleteTriger">Delete</button><th>
voici mon index.php
action.php
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 <!DOCTYPE html> <html> <title>Datatable Bulk Delete Server Side | CoderExample</title> <head> <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css"> <link rel="stylesheet" type="text/css" href="css/bouton.css"> <script type="text/javascript" language="javascript" src="js/jquery.js"></script> <script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script> <script type="text/javascript" language="javascript" > $(document).ready(function() { var dataTable = $('#vu_affect_empl').DataTable( { "processing": true, "serverSide": true, "columnDefs": [ { "targets": 0, "orderable": false, "searchable": false } ], "ajax":{ url :"Affectation.php", // json datasource type: "post", // method , by default get error: function(){ // error handling $(".vu_affect_empl-error").html(""); $("#vu_affect_empl").append('<tbody class="vu_affect_empl-error"><tr><th colspan="3"></th></tr></tbody>'); $("#vu_affect_empl_processing").css("display","none"); } } } ); $("#bulkDelete").on('click',function() { // bulk checked var status = this.checked; $(".deleteRow").each( function() { $(this).prop("checked",status); }); }); $('#deleteTriger').on("click", function(event){ // triggering delete one by one if( $('.deleteRow:checked').length > 0 ){ // at-least one checkbox checked var ids = []; $('.deleteRow').each(function(){ if($(this).is(':checked')) { ids.push($(this).val()); } }); var ids_string = ids.toString(); // array to string conversion $.ajax({ type: "POST", url: "employee-delete.php", data: {data_ids:ids_string}, success: function(result) { dataTable.draw(); // redrawing datatable }, async:false }); } }); } ); </script> <style> div.container { margin: 0 auto; max-width:760px; } div.header { margin: 100px auto; line-height:30px; max-width:760px; } body { background: #f7f7f7; color: #333; font: 90%/1.45em "Helvetica Neue",HelveticaNeue,Verdana,Arial,Helvetica,sans-serif; } </style> </head> <body> <div class="header"> <h2 align="center">Affectation</h2><br /></div> <center> <a href="Abonnement.php" class="bouton_dans_page">Abonnement</a> <a href="Employe.php" class="bouton_dans_page"> Employe</a> <a href="Equipement.php" class="bouton_dans_page"> Equipement</a> <a href="Modele.php" class="bouton_dans_page"> Modele</a> <a href="Nouvelle_Affectation.php" class="bouton_dans_page"> Nouvelle Affectation</a> <a href="Employe.php" class="bouton_dans_page"> Employe</a> <a href="Menu_Smartphone.html" class="bouton_dans_page"> Menu Smarphone</a> </center> <center> <table id="vu_affect_empl" cellpadding="0" cellspacing="0" border="0" class="display" width="100%"> <thead> <tr> <th><input type="checkbox" id="bulkDelete"/><button id="deleteTriger">Delete</button><th> <th>USER ID</th> <th>Nom</th> <th>Prenom</th> <th>Num SIM</th> <th>PIN Terminal</th> <th>PIN SIM</th> <th>Num EMEI</th> <th>Date Debut</th> <th>Date Fin</th> <th>Vitre</th> <th>Coque</th> <th>Support Vehicule</th> <th>Actif</th> <th>Statut</th> </tr> </thead> </table><br><br> <button type="button" class="Menu" id="Supprimer_affect" name="Supprimer_affect" onclick="Confirm.render()">Suprimer Affectation</button> <button class="Menu" type="button" id="C_R_E" onclick="javascript:Confirmer" name="C_R_E">Confirmer Retour Equipement</button> <a href="Equipement_Modal.php" class="Menu" id="R_E" name="R_E"> Remplacer Equipement</a> <button class="Menu" type="button" id="A_S_L" name="A_S_L">Ajout et Supression Ligne</button> <button class="Menu" type="button" id="C_R_A" name="C_R_A">Confirmer Retour Abonnement</button> <button class="Menu" type="button" id="Reaff_Equip" name="Reaff_Equip">Reaffectation Equipement</button> </center> </body> </html>
merci de votre aide
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 <?php $servername = "localhost"; $username = "root"; $password = "Mm101010"; $dbname = "smartphone"; $conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); $requestData = $_REQUEST; $columns = array( 0 => 'USER_ID', 1 => 'Nom', 2 => 'Prenom', 3 => 'Num_SIM', 4 => 'PIN_Terminal', 5 => 'PIN_SIM', 6 => 'Num_IMEI', 7 => 'Date_Debut', 8 => 'Date_Fin', 9 => 'Vitre', 11 => 'Coque', 12 => 'Support_Vehicule', 13 => 'Actif', 14 => 'Statut' ); $sql = "SELECT Or_Affectation "; $sql.=" FROM vu_affect_empl"; $query=mysqli_query($conn, $sql) or die("Affectation.php: get employees"); $totalData = mysqli_num_rows($query); $totalFiltered = $totalData; $sql = "SELECT Or_Affectation, USER_ID, Nom, Prenom, Num_SIM, PIN_Terminal, PIN_SIM, Num_IMEI, Date_Debut, Date_Fin, Vitre, Coque, Support_Vehicule, Actif, Statut "; $sql.=" FROM vu_affect_empl WHERE 1=1"; if( !empty($requestData['search']['value']) ) { $sql.=" AND ( USER_ID LIKE '".$requestData['search']['value']."%' "; $sql.=" OR Num_SIM LIKE '".$requestData['search']['value']."%' "; $sql.=" OR Nom LIKE '".$requestData['search']['value']."%' )"; } $query=mysqli_query($conn, $sql) or die("Affectation.php: get employees"); $totalFiltered = mysqli_num_rows($query); $sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." "; $query=mysqli_query($conn, $sql) or die("Affectation.php: get employees"); $data = array(); $i=1+$requestData['start']; while( $row=mysqli_fetch_array($query) ) { $nestedData=array(); $nestedData[] = "<input type='checkbox' class='deleteRow' value='".$row['Or_Affectation']."' /> N°".$i ; $nestedData[] = $row["USER_ID"]; $nestedData[] = $row["Nom"]; $nestedData[] = $row["Prenom"]; $nestedData[] = $row["Num_SIM"]; $nestedData[] = $row["PIN_Terminal"]; $nestedData[] = $row["PIN_SIM"]; $nestedData[] = $row["Num_IMEI"]; $nestedData[] = $row["Date_Debut"]; $nestedData[] = $row["Date_Fin"]; $nestedData[] = $row["Vitre"]; $nestedData[] = $row["Coque"]; $nestedData[] = $row["Support_Vehicule"]; $nestedData[] = $row["Actif"]; $nestedData[] = $row["Statut"]; $data[] = $nestedData; $i++; } $json_data = array( "draw" => intval( $requestData['draw'] ), "recordsTotal" => intval( $totalData ), "recordsFiltered" => intval( $totalFiltered ), "data" => $data ); echo json_encode($json_data); ?>
Partager