【发布时间】:2022-01-11 09:37:30
【问题描述】:
我不知道为什么,但即使没有任何问题,也不会出现搜索和 pdf、打印等按钮。
这是我当前的表:
这是代码:
<table id="example1" class="table table-bordered table-striped dataTable no-footer">
<thead>
<tr>
<th>No.</th>
<th>Trimester</th>
<th>Role</th>
<th>Before</th>
<th>Due Date</th>
<th>After</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="4" class="bg-white">1.</td>
<td rowspan="4" class="bg-white">[2110] Trimester 1 - 2021/2022</td>
<td>Coordinator</td>
<td>10/12/2021</td>
<td>12/12/2021</td>
<td>13/12/2021</td>
<td>
<div class="d-flex">
<button type="submit" class="btn btn-warning btn-xs mr-1">Edit</button></form>
<a type="submit" class="btn btn-danger btn-xs">Remove</a>
</div>
</td>
</tbody>
</table>
我删除了这里的一些代码,因为它太长了
这就是我想要实现的目标:
Table that have search and buttons
这是我的数据表脚本函数:
$(function () {
$("#example1").DataTable({
"responsive": true, "lengthChange": false, "autoWidth": false,
"buttons": ["excel", "pdf", "print"]
}).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
});
注意:我注意到 rowspan 使表格出错,但我确实需要该 rowspan。
【问题讨论】:
-
嗨 Shahir,您的代码中有一个意外的 标记同时从表格中删除按钮 div 并移至表格顶部。
-
我认为您缺少数据表库
标签: html bootstrap-4