【发布时间】:2022-01-06 01:50:19
【问题描述】:
所以我正在使用 dataTables,但在我的表格上显示复选框时遇到了麻烦。所以我有这个代码:
<table id="employeeList" class="table table-sm table-bordered table-hover" cellspacing="0" width="200%">
<thead class="blue lighten-2">
<tr>
<th>RTO</th>
<th>Name</th>
<th>Address</th>
<th>RTO Score</th>
<th>Production Machine</th>
<th>Transportation Availability</th>
<th>Department/Team</th>
<th>Return to Office Date</th>
<th>Willingness</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>Sample</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
<tr>
<td></td>
<td>Sample2</td>
<td>1</td>
<td>123</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
<td>asd</td>
</tr>
</tbody>
我有一个脚本,它使 dataTable 能够同时进行垂直和水平滚动,并且应该是第一个子表上的复选框。
<script>
$(document).ready(function () {
$('#employeeList').dataTable({
"scrollX": true,
"scrollY": 350,
columnDefs: [{
orderable: false,
className: 'select-checkbox',
targets: 0
}],
select: {
style: 'os',
selector: 'td:first-child'
}
});
$('.dataTables_length').addClass('bs-select');
});
我错过了什么吗?非常感谢您的帮助。
【问题讨论】:
-
你需要把标签移到下,看看是否解决。哦,是的,抱歉,它通常在 标记之外。我在创建这个时打错了。它仍然无法正常工作。
标签: javascript html bootstrap-4