How to remove sorting option from DataTables?

Ok, so, the answers here are a bit old. So I thought I could provide e newer answer:

source documentation

As of 2018, the way to achieve this, per field, is:

$('#id-of-my-table').DataTable({
    "columnDefs": [
        { "orderable": false, "targets": [0, 4, 5, 6] },
        { "orderable": true, "targets": [1, 2, 3] }
    ]
});

As you can see, targets accepts an array of column indexes.


You can also pass the option on the table itself using data attributes.

<table
   data-paging="false"
   data-searching="false"
   data-ordering="false"
>

The same principle applies to column headers.

<table>
<thead>
<tr>
    <th>I'm sortable</th>
    <th data-orderable="false">I'm not sortable</th>
</tr>
</thead>

But, I came across a situation where I wanted to remove all columns sorting and realize that Datatable still adds the icon on the first column when using a th data-orderable="false" on all columns, in that case, use the data-ordering on the table instead.

This can be handy should you use the same custom script to generate all your Datatables.


In the new version 1.10 of jQuery DataTables you must use ordering option to disable ordering on the entire table:

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

Very similar to @ravisolanki07 , it's just a different way to achieve this.

var oTable = $('#example').dataTable( {
    "aoColumnDefs": [
        { "bSortable": false, "aTargets": [ 0, 1, 2, 3 ] }, 
        { "bSearchable": false, "aTargets": [ 0, 1, 2, 3 ] }
    ]
});