您好,我有以下表格设计。我不希望第一列和最后一列是可排序的。我已经相应地设置了。但是图标 asc 仍然出现在第一列而不是最后一列。但是当我尝试对第二列进行排序时,它会消失。
<table id="userTable" name='userTable' class="table table-striped table-bordered bootstrap-datatable " data-column-defs='[{"sortable": false, "targets": [0,3]}]' style='table-layout: fixed;'>
<thead>
<tr>
<th class="no-sort" style='width: 10%;'>No.</th>
<th style='width: 25%;'>First Name</th>
<th style='width: 20%;'>last Name</th>
<th style='width: 25%;'>Details</th>
</tr>
</thead>
</table>
最佳答案
即使您禁用列排序,dataTables 也会排序 order
仍然保持。默认order
是[0, 'asc']
;只需将 order
设置为以 #2 列为目标即可:
var table = $('#example').DataTable({
//....
order: [[ 1, "asc" ]] //column indexes is zero based
})
演示 -> http://jsfiddle.net/6k26o7mk/
如果您根本不需要任何默认顺序,或者使用 order: []
(图标将隐藏,直到用户对表格进行排序)。
关于php - 即使被禁用,数据表排序 asc 图标仍然出现在第一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35521666/