gpt4 book ai didi

jquery - 如何禁用数据表中仅某一特定列的排序?

转载 作者:行者123 更新时间:2023-12-03 22:19:38 27 4
gpt4 key购买 nike

假设我有如下表:

And I want to disable sorting of Action Column

<!--index.html-->      
<table class="table table-striped table-bordered post-list-table" id="table" >
<thead>
<tr>
<th>Title</th>
<th>Created At</th>
<th>Action</th>
</tr>
</thead>
</table>

<!--Script.js-->
$('#table').DataTable();

最佳答案

尝试添加: columns.orderable

"columnDefs": [
{ "orderable": false, "targets": 2 }
]

JSFiddle Here

<!--Script.js-->
$('#table').DataTable( {
"columnDefs": [
{ "orderable": false, "targets": 2 }
]
});
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet"/>

<table class="table table-striped table-bordered post-list-table" id="table" >
<thead>
<tr>
<th>Title</th>
<th>Created At</th>
<th>Action</th>
</tr>
</thead>
</table>

关于jquery - 如何禁用数据表中仅某一特定列的排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47322035/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com