我已经成功为我的HTML表格使用了DataTables插件,但是,虽然点击顶部行会导致表格按所点击的列进行排序,但排序箭头却没有显示。
这是我通过CDN引用DataTables资产的方式:
<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
下面是在运行时检查表格的样子:
dataTables.bootstrap.min.css
添加的。 - undefineddataTable
з±»гЂЃдёЂдёЄtheadе’Ње…·жњ‰.sorting
з±»зљ„еЌ•е…ѓж јгЂ‚ењЁж‚Ёзљ„жѓ…е†µдё‹зјєе°‘д»Ђд№€пјџ - undefined$('#example').DataTable( { "order": [[ 3, "desc" ]] //大小写敏感 } );
是用来初始化数据表格并设置排序规则的。 - undefined