【发布时间】:2016-09-27 18:19:15
【问题描述】:
我已经为我的 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>
...但没有区别。
更新 3
这是检查时表在运行时的样子:
【问题讨论】:
-
是否包含引导 css?表类与演示匹配吗?只要包含设置和所有依赖项,就没有理由不能全部从 cdn 工作
-
箭头由
dataTables.bootstrap.min.css添加 -
并取决于具有
dataTable类的表、一个thead 和具有.sorting类的单元格。您的情况缺少什么? -
不,我相信这是 DataTables 添加的内容。检查您的表,看看它是否被添加。 并停止向您的问题添加“UPDATE”标题。更新现有问题,而不是留下陈旧的代码示例。
-
datatables.net/examples/basic_init/table_sorting.html 会帮助你。请注意,您应该在引导 css 文件之后添加 dataTables.bootstrap.min.css 文件。
$('#example').DataTable( { "order": [[ 3, "desc" ]] //Case sensitive } );
标签: jquery image sorting datatables cdn