簡體   English   中英

如何禁用對數據表中的列進行排序

[英]How to disable sorting on a column in a datatable

我試圖在我的其中一列上禁用排序功能。
我已經嘗試了多種方法,但是這些方法沒有用。
我嘗試在我的<th>添加以下內容: data-sorter="false" ,但它只是忽略了它。
我也嘗試過,但也忽略了它:

“columnDefs”: [ {
“targets”: 2,
“orderable”: false
}]

當我嘗試這些方法時,我沒有得到任何錯誤。 我還發現使用inspect元素,我的<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天的答案。

您是否嘗試設置"bSort":false 欲了解更多詳情,請參閱


禁用從數據表排序

"bSort":false


要禁用對特定列的排序:

"bSortable": false


更加具體:

  $('#table').dataTable( { "bSort":true, aoColumnDefs: [ { aTargets: [ '_all' ], bSortable: false }, { aTargets: [ 0 ], bSortable: true }, { aTargets: [ 1 ], bSortable: true } ] } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM