How to Disable sorting of only one specific column in Data tables?
Do this in jQuery
var table = $('#tbl').DataTable({
"columnDefs": [{ targets: 'no-sort', orderable: false }]});
and add a class 'no-sort' to whatever headers you want to disable sort like this..
<th class="no-sort">Header n</th>
Try adding : 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>