【发布时间】:2016-12-09 20:37:29
【问题描述】:
您好,我想在数据表中添加行选择 复选框,还需要针对每一行添加复选框。这样它将单独选择行。
谢谢。
【问题讨论】:
-
不知道你的工作环境,什么样的语言,框架?
-
我在 php 框架中工作,我已经添加了数据表来显示来自 databade 的结果。
-
谢谢,会检查的。
标签: php datatables
您好,我想在数据表中添加行选择 复选框,还需要针对每一行添加复选框。这样它将单独选择行。
谢谢。
【问题讨论】:
标签: php datatables
您可以使用以下代码 JS:
$(document).ready(function() {
$('#example').DataTable( {
columnDefs: [ {
orderable: false,
className: 'select-checkbox',
targets: 0
} ],
select: {
style: 'os',
selector: 'td:first-child'
},
order: [[ 1, 'asc' ]]
} );
} );
HTML
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tr>
<td></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
</table>
【讨论】:
row.add([]),这不会添加复选框