Javascript datatables.net:如何在datatables中使用responsive plus复选框?
我正在为表使用Datatable.net框架 我的问题是,我想在同一个数据表中有两个东西,一个是响应的,第二个是复选框 这是我用于此的脚本Javascript datatables.net:如何在datatables中使用responsive plus复选框?,javascript,datatables,Javascript,Datatables,我正在为表使用Datatable.net框架 我的问题是,我想在同一个数据表中有两个东西,一个是响应的,第二个是复选框 这是我用于此的脚本 $(document).ready(function() { $('#example').DataTable( { responsive: true, columnDefs: [ { orderable: false, className: 'select-checkbo
$(document).ready(function() {
$('#example').DataTable( {
responsive: true,
columnDefs: [ {
orderable: false,
className: 'select-checkbox',
targets: 0
} ],
select: {
style: 'os',
selector: 'tr'
},
order: [[ 1, 'asc' ]]
} );
} );
这是我正在使用的HTML。
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
</tbody>
</table>
名称
位置
办公室
年龄
薪水
名称
位置
办公室
年龄
薪水
老虎尼克松
系统架构师
爱丁堡
61
$320,800
我认为您遗漏了一些东西,如果您想使用Datatables的扩展,那么您应该添加扩展库,否则它将无法工作
因此,您可以在此链接中看到工作代码
JavaScript
$(document).ready(function() {
$('#example').DataTable( {
responsive: true,
columnDefs: [ {
orderable: false,
className: 'select-checkbox',
targets: 0
} ],
select: {
style: 'os',
selector: 'tr'
},
order: [[ 1, 'asc' ]]
} );
} );
HTML
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
</tbody>
名称
位置
办公室
年龄
薪水
名称
位置
办公室
年龄
薪水
老虎尼克松
系统架构师
爱丁堡
61
$320,800
扩展链接在这里我认为您遗漏了一些东西,如果您想使用Datatables的扩展,那么您应该添加扩展库,否则它将无法工作 因此,您可以在此链接中看到工作代码 JavaScript
$(document).ready(function() {
$('#example').DataTable( {
responsive: true,
columnDefs: [ {
orderable: false,
className: 'select-checkbox',
targets: 0
} ],
select: {
style: 'os',
selector: 'tr'
},
order: [[ 1, 'asc' ]]
} );
} );
HTML
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td></td>
<td>Tiger Nixon</td>
<td>System Architect</td>
<td>Edinburgh</td>
<td>61</td>
<td>$320,800</td>
</tr>
</tbody>
名称
位置
办公室
年龄
薪水
名称
位置
办公室
年龄
薪水
老虎尼克松
系统架构师
爱丁堡
61
$320,800
扩展链接在这里您是否添加了响应库,该库来自您的页面中的datatables插件是的,我添加了,并且它工作正常。。。如果我使用复选框,那么您添加的响应库不是WorkID,它来自于您页面中的datatables插件是的,我添加了,它已工作。。。如果我使用复选框,那么它不是工作感谢回复@您的代码是否正常工作。我需要多个复选框选择。在手机中没有“ctrl”按钮。我们在那里做什么?为什么你需要“ctrl”按钮,如果你解释你想做什么,那么我们可以找到解决方案。谢谢你的回复@您的代码是否正常工作。我需要多个复选框选择。在手机中没有“ctrl”按钮。我们在那里做什么?为什么需要“ctrl”按钮,如果你解释你想做什么,那么我们就可以找到解决方案。