【发布时间】:2021-10-11 17:17:42
【问题描述】:
我要做的是对具有复选框的数据表列进行排序。问题是:它不起作用,因为我正在更改列值。 由于它不是ajax生成的,我不能使用reload()方法,如何重绘它?
<table id="tableEditable">
<thead>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
</tr>
</thead>
<tbody>
<tr>
<td>Info 1</td>
<td>Info 2</td>
<td><span id="spanChk1">0</span><input type="checkbox" id="chk1" onclick="changeValue('spanChk1', this.checked)"></td>
</tr>
<tr>
<td>Info 3</td>
<td>Info 4</td>
<td><span id="spanChk2">0</span><input type="checkbox" id="chk2" onclick="changeValue('spanChk2', this.checked)"></td>
</tr>
</tbody>
</table>
<script>
$(document).ready(function () {
$('#tableEditable').DataTable({
"columnDefs": [
{
"targets": 2,
"orderDataType": "dom-checkbox"
}
],
"paging": false,
"order": [[1, "asc"]]
});
});
function changeValue(spanId, checked)
{
if (!checked)
$("#" + spanId).text('0');
else
$("#" + spanId).text('1');
}
</script>
【问题讨论】:
标签: jquery datatable datatables