Bonjour,

Je suis actuellement en train de créer un tableau avec le plug-in DataTable et je cherche à y insérer un champ DatePicker qui, lorsque l'envent DateChange arrive, check ma checkbox en début de ligne.
Pour l'instant une seule de mes lignes fonctionne et ce n'est ni la première ni la dernière.

Voici mon code PHP :
Code html : 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
<table id="example" class="table table-striped hover select display">
	<thead>
		<tr>
			<th><input name="select_all" value="1" type="checkbox"></th>
			<th style="vertical-align: middle; text-align: center;">Logiciel</th>
			<th style="vertical-align: middle; text-align: center;"></th>
			<th style="vertical-align: middle; text-align: center;">Description</th>
			<th style="vertical-align: middle; text-align: center;">Date de déb</th>
			<th style="vertical-align: middle; text-align: center;">Date de fin</th>
			<th style="vertical-align: middle; text-align: center;">Commentaire archiv</th>
			<th style="vertical-align: middle; text-align: center;">Phase déploi</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach ($data['Vrs'] as $key => $listApp) : ?>
			<tr role="row">
				<td id="<?= $listApp->{mVVrs::M_CD_LOGI}?><?= $listApp->{mVVrs::M_ID_VRS}?>"><?= $listApp->{mVVrs::M_CD_LOGI}?><?= $listApp->{mVVrs::M_ID_VRS}?></td>
				<td><?= $listApp->{mVVrs::M_LIB_LNG}?></td>
				<td align="center"><?= $listApp->{mVVrs::M_ID_VRS}?></td>
				<td><?= $listApp->{mVVrs::M_DTL_COMPL}?></td>
				<td align="center"><?php echo convertDateFr($listApp->{mVVrs::M_DT_DEB}); ?></td>
				<td align="center">
					<div class="input-group date dt-fin" data-provide="datepicker">
						<input type="text" class="form-control" value="<?php echo convertDateFr($listApp->{mVVrs::M_DT_FIN}); ?>">
					<div class="input-group-addon">
					</div>
					</div>
				</td>
				<td align="center"><?= $listApp->{mVVrs::M_COMMT_ARCHIV }?></td>
				<td align="center"><?= $listApp->{mVVrs::M_LIB_PHASE}?></td>
			</tr>
		<?php endforeach; ?>
	</tbody>
</table>
 
function convertDateFr($date)
{
	if(strlen($date) != 10){
		return false;
	}else{
		list( $annee, $mois, $jour ) = sscanf( $date, "%d-%d-%d" );
		if($mois < 10){
			$mois = "0" . $mois;
		}
		if($jour < 10){
			$jour = "0" . $jour;
		}
		return date("d/m/Y",strtotime($mois . "/" . $jour . "/" . $annee));
	}
}
 
?>

Et là mon code JS avec Jquery
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<script type="text/javascript">
<!--
 
//
// Updates "Select all" control in a data table
//
function updateDataTableSelectAllCtrl(table){
	var $table             = table.table().node();
	var $chkbox_all        = $('tbody input[type="checkbox"]', $table);
	var $chkbox_checked    = $('tbody input[type="checkbox"]:checked', $table);
	var chkbox_select_all  = $('thead input[name="select_all"]', $table).get(0);
 
	// If none of the checkboxes are checked
	if($chkbox_checked.length === 0){
		chkbox_select_all.checked = false;
		if('indeterminate' in chkbox_select_all){
			chkbox_select_all.indeterminate = false;
		}
 
	// If all of the checkboxes are checked
	} else if ($chkbox_checked.length === $chkbox_all.length){
		chkbox_select_all.checked = true;
		if('indeterminate' in chkbox_select_all){
			chkbox_select_all.indeterminate = false;
		}
 
	// If some of the checkboxes are checked
	} else {
		chkbox_select_all.checked = true;
		if('indeterminate' in chkbox_select_all){
			chkbox_select_all.indeterminate = true;
		}
	}
}
 
$(document).ready(function (){
 
	// Array holding selected row IDs
	var rows_selected = [];
	var table = $('#example').DataTable({
		'columnDefs': [
			{
				'targets': 0,
				'searchable': false,
				'orderable': false,
				'width': '1%',
				'className': 'dt-body-center',
				'render': function (data, type, full, meta)
					{ return '<input type="checkbox">'; }
			},
			{ "orderable": false, "targets": 2 },
			{ "orderable": false, "targets": 3 },
			{ "orderable": false, "targets": 6 },
			{ "type" : 'date-eu', "target" : 4 },
			{ "type" : 'date-eu', "target" : 5 },
		],
		'order': [[1, 'asc']],
		"language": {
			"lengthMenu":     "Afficher _MENU_ résultats par page",
			"zeroRecords":    "Aucun résultat trouvé",
			"infoEmpty":      "Pas de données trouvé dans ce tableau",
			"infoFiltered":   "(filtrer sur _MAX_ résultats)",
			"search":         "Rechercher : ",
			"decimal":        ",",
			"emptyTable":     "Pas de données dans ce tableau",
			"info":           "Résultats _START_ à _END_ sur _TOTAL_",
			"infoPostFix":    "",
			"thousands":      ".",
			"loadingRecords": "Chargement...",
			"processing":     "Recherche...",
			"paginate": {
			    "first":    "Première",
			    "last":     "Dernière",
			    "next":     "Suivante",
			    "previous": "Précédente"
			}
		},
		"stateSave": true,
		stateSaveCallback: function(settings,data) {
		    localStorage.setItem( 'DataTables_' + settings.sInstance, JSON.stringify(data) )
		},
		stateLoadCallback: function(settings) {
		    return JSON.parse( localStorage.getItem( 'DataTables_' + settings.sInstance ) )
		},
		'rowCallback': function(row, data, dataIndex){
			// Get row ID
			var rowId = data[0];
 
			// If row ID is in the list of selected row IDs
			if($.inArray(rowId, rows_selected) !== -1){
				$(row).find('input[type="checkbox"]').prop('checked', true);
				$(row).addClass('selected');
			}
		}
	});
 
	// Handle click on checkbox
	$('#example tbody').on('click', 'input[type="checkbox"]', function(e){
		var $row = $(this).closest('tr');
 
		// Get row data
		var data = table.row($row).data();
 
		// Get row ID
		var rowId = data[0] + data[2];
 
		// Determine whether row ID is in the list of selected row IDs 
		var index = $.inArray(rowId, rows_selected);
 
		// If checkbox is checked and row ID is not in list of selected row IDs
		if(this.checked && index === -1){
			rows_selected.push(rowId);
 
		// Otherwise, if checkbox is not checked and row ID is in list of selected row IDs
		} else if (!this.checked && index !== -1){
			rows_selected.splice(index, 1);
		}
 
		if(this.checked){
			$row.addClass('selected');
		} else {
			$row.removeClass('selected');
		}
 
		// Update state of "Select all" control
		updateDataTableSelectAllCtrl(table);
 
		// Prevent click event from propagating to parent
		e.stopPropagation();
	});
 
	// Handle click on "Select all" control
	$('thead input[name="select_all"]', table.table().container()).on('click', function(e){
		if(this.checked){
			$('#example tbody input[type="checkbox"]:not(:checked)').trigger('click');
		} else {
			$('#example tbody input[type="checkbox"]:checked').trigger('click');
		}
 
		// Prevent click event from propagating to parent
		e.stopPropagation();
	});
 
	// Handle table draw event
	table.on('draw', function(){
		// Update state of "Select all" control
		updateDataTableSelectAllCtrl(table);
	});
 
	// Handle form submission event 
	$('#submit-example').on('click', function(e){
		var form = this;
		// Iterate over all selected checkboxes
		$.each(rows_selected, function(index, rowId){
			// Create a hidden element 
			$(form).append(
				$('<input>')
					.attr('type', 'hidden')
					.attr('name', 'id[]')
					.val(rowId)
			);
		});
		console.log('form=' + JSON.stringify($(form)));
 
		$('#example-console').text($(form).serialize());
		console.log("Form submission", $(form));
 
		// Remove added elements
		$('input[name="id\[\]"]', form).remove();
 
		// Prevent actual form submission
		e.preventDefault();
	});
 
	function display(msg) {
		console.log(msg);
	}
 
	$('.dt-fin').datepicker({
		format: "dd/mm/yyyy",
		weekStart: 1,
		maxViewMode: 3,
		language: "fr",
		daysOfWeekHighlighted: "1,2,3,4,5",
		calendarWeeks: true,
		todayHighlight: true,
		autoclose: true
 
	}).on("changeDate", function() {
		var $row = $(this).closest('tr');
		var data = table.row($row).data()
 
		console.log($('#' + data[0]).find('input'));
		console.log('#' + data[0]);
 
		$("#example").find('#' + data[0]).find('input').prop("checked", true);
 
		// Update state of "Select all" control
		updateDataTableSelectAllCtrl(table);
	});
});
Je n'ai peut être pas été clair alors si vous ne comprenez pas n'hésiter pas à me demander des précision

Merci d'avance pour l'aide