【发布时间】:2019-03-07 07:48:40
【问题描述】:
我正在尝试禁用我的某一列的排序功能。
我已经尝试了多种方法,但这些都不起作用。
我尝试将这个:data-sorter="false" 添加到我的<th>,但它只是忽略了它。
我也试过这个,但它也忽略了它:
“columnDefs”: [ {
“targets”: 2,
“orderable”: false
}]
当我尝试这些方法时,我没有收到任何错误。
我还发现使用检查元素,我的<th> 会自动将sorting 类添加到其中。
这是我的代码:
我的桌子:
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Vraag</th>
<th>Gepost op</th>
<th>Acties</th>// I want to disable sorting here
</tr>
</thead>
<tbody>
</tbody>
</table>
我的 js:
// Call the dataTables jQuery plugin
$(document).ready(function() {
$('#dataTable').DataTable({
"columnDefs": [ {
"targets": 2,
"orderable": false
} ]
});
});
请帮助我,过去 3 天我一直在寻找答案。
【问题讨论】:
标签: javascript jquery html-table datatable