0
dataCompetence
の値が2,5
のajax応答コードがあります。私は同じIDを列comp_id
に見つけようとして、チェックボックスにチェックを入れました。ここに私のhtmlコードは次のとおりです。DatatableでAjaxレスポンスからチェックボックスをチェックする方法
<table id="competence_list" class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th width="1%"><input name="select_all_competence" class="case" id="example-select-all-competence" type="checkbox"></th>
<th hidden>ID</th>
<th width="10%">Aspect</th>
<th width="40%">Description</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
if ($this->competenceList) {
foreach ($this->competenceList as $data) {
?>
<tr>
<td><input type="checkbox" name="idcheckbox_competence" id="idcheckbox_competence" class="case"></td>
<td hidden id="comp_id"><?php echo $data['competence_id']; ?></td>
<td><?php echo $data['aspect']; ?></td>
<td><?php echo $data['descriptions']; ?></td>
</tr>
<?php
$i++;
}
}
?>
</tbody>
</table>
と私がチェックし、チェックボックスを設定しようとしたものを、この:
var dataCompetence = jsonData.dataCompetence;
if(jsonData.success){
$.gritter.removeAll();
$.each(dataCompetence.split(","), function(i,e){
$("#competence_list input[value='" + e + "']").prop("checked", true);
});
私は同じ値を見つけるために、OWを知っているし、その後にチェック]チェックボックスを設定していない、私を助けて。おかげ