Datatables 删除列的排序

Datatables 删除列的排序,datatables,Datatables,试图关闭表中特定列的排序,但会影响错误的列吗?有人能看到我在这里遗漏了什么吗 HTML 非常感谢 编辑:添加结果的图像。如您所见,错误的列会受到影响 在jQuery DataTables的新版本1.10中,您必须使用ordering选项来禁用对整个表的排序: $('#tableListing').DataTable({ "ordering": false }); 您还可以对特定列使用as,如下所示: $(document).ready(function() { oTable = jQu

试图关闭表中特定列的排序,但会影响错误的列吗?有人能看到我在这里遗漏了什么吗

HTML

非常感谢

编辑:添加结果的图像。如您所见,错误的列会受到影响


在jQuery DataTables的新版本1.10中,您必须使用ordering选项来禁用对整个表的排序:

$('#tableListing').DataTable({
    "ordering": false
});

您还可以对特定列使用as,如下所示:

$(document).ready(function() {
oTable = jQuery('#tableListing').dataTable( {           
            "bDestroy": true,
            "bAutoWidth": true,  
            "bFilter": true,
            "bSort": true, 
            "aaSorting": [[0]],         
            "aoColumns": [
                { "bSortable": false },
                { "bSortable": true },
                { "bSortable": true },
                { "bSortable": true },
                { "bSortable": true },
                { "bSortable": true },
                { "bSortable": false }
            ]   
        } );
 })

您可以排除不希望将排序设置为“可排序为false”的列。

如果您只想取消对特定列的排序,可以这样做:

$('#tableListing').DataTable({
    columnDefs: [
        { "orderable": false, "targets": [ 0, 4 ] }
    ]
});
或者,您可以在要禁止排序的列标题中添加一个类似“no sort”的类

<thead>
  <tr>
   <th class="no-sort"></th>
   <th>Personnumer</th>
   <th>Namn</th>
   <th>Skapad</th>
   <th class="no-sort"></th>
  </tr>
 </thead>

你可以看到我的更新答案..上面添加的图片,请再看一看?排序受到限制,但会影响错误的列。添加了图像,请重新查看?排序受到限制,但错误的列会受到影响。在我看来,这些列是正确的。您想限制第1列和第5列的排序。这正是图像所显示的。也许需要澄清一下:箭头出现在它们影响的列的右侧。我还将更新我的答案,因为“no sort”类显然有效。
$('#tableListing').DataTable({
    columnDefs: [
        { "orderable": false, "targets": [ 0, 4 ] }
    ]
});
<thead>
  <tr>
   <th class="no-sort"></th>
   <th>Personnumer</th>
   <th>Namn</th>
   <th>Skapad</th>
   <th class="no-sort"></th>
  </tr>
 </thead>
$('#tableListing').DataTable({
        columnDefs: [
            { "orderable": false, "targets": 'no-sort' }
        ]
    });