我已经为我的html表格设置了DataTables插件,但是,虽然点击顶部一行会使表格按点击的列排序,但是排序箭头并没有显示出来。
这就是我引用DataTable资产的方式(通过CDN):
<link href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>然后我像这样戳这个插件:
$('#delperfTable').DataTable({
"paging": false,
"info": false,
"searching": false
});排序工作正常,但不显示方便的可视指示器。我想,如何才能让这些排序箭头按照默认行为显示呢?
我在谷歌上看到了一些关于需要“拉出图像”的信息,但如果可能的话,我想通过CDN参考这些图像。
更新
注意:我还有:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>HTML是:
<div class="col-md-6">
<div class="bottomright">
<h2 class="sectiontext">Delivery Performance</h2>
<table id="delperfTable">
<thead>
<tr>
<th>PRO*ACT Distributor</th>
<th>Restaurant Location</th>
<th class="rightjustifytext">Avg Order Amount</th>
<th class="rightjustifytext">Avg Package Count</th>
<th class="rightjustifytext">Total Sales</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sunrise FL</td>
<td>A1A ALEWORKS - #4405 - ST. AUGUSTINE</td>
<td class="rightjustifytext">$475.78</td>
<td class="rightjustifytext">28.50</td>
<td class="rightjustifytext">$1,903.10</td>
</tr>
. . . // other trs elided for brevity
<tr class="bold">
<td>TOTAL</td>
<td></td>
<td class="rightjustifytext">375.11</td>
<td class="rightjustifytext">23.50</td>
<td class="rightjustifytext">$7,966.68</td>
</tr>
</tbody>
</table>
</div>
</div>更新2
我添加了两个类,一个添加到表中,一个添加到列中,如下所示:
<table id="delperfTable" class="dataTable">
<thead>
<tr>
<th class="sorting">PRO*ACT Distributor</th>...but它没有什么不同。
更新3
下面是表在运行时被检查时的外观:

发布于 2020-06-04 00:30:37
您的代码在以下行中缺少rel="stylesheet":
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />这会导致浏览器静默地无法包含dataTables.bootstrap.min.css,这是表排序上/下箭头显示的位置。
在DataTables 1.10.21中,dataTables.bootstrap.css (用于Bootstrap 3)包含:
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after,
table.dataTable thead .sorting_asc_disabled:after,
table.dataTable thead .sorting_desc_disabled:after {
position: absolute;
bottom: 8px;
right: 8px;
display: block;
font-family: 'Glyphicons Halflings';
opacity: 0.5;
}
table.dataTable thead .sorting:after {
opacity: 0.2;
content: "\e150";
/* sort */
}
table.dataTable thead .sorting_asc:after {
content: "\e155";
/* sort-by-attributes */
}
table.dataTable thead .sorting_desc:after {
content: "\e156";
/* sort-by-attributes-alt */
}如果使用的是Bootstrap 4,则要使用的文件是dataTables.bootstrap4.css
https://stackoverflow.com/questions/39731718
复制相似问题