How to disable sorting with jquery datatable
By Tan Lee Published on Feb 16, 2024 1.02K
To disable sorting in a jQuery DataTable, you can use the ordering option in the DataTable initialization.
Setting ordering
to false
will prevent sorting functionality on the table.
$('#table').dataTable( { "ordering": false // Disable sorting } );
This will disable the sorting functionality for all columns in the table. If you want to disable sorting only on specific columns, you can use the columnDefs
option.
For example, disable sorting on specific columns (e.g., columns 0 and 1):
$(document).ready(function() { $('#example').DataTable({ "columnDefs": [ { "orderable": false, "targets": [0, 1] } // Disable sorting on column 0 and 1 ] }); });
This way, sorting will be disabled for the specified columns, but the rest of the table will still be sortable.
- How to add class to tr using jQuery datatable
- How to hide “Showing 1 of N Entries” with jQuery datatables
- How to Change parameter used in datatables ajax url.Action on Ajax.reload
- How to fix 'Requested unknown parameter '6' for row 0, column 6'
- How to Add new row to datatable using jquery datatable
- Ho to add class to column dynamically using jQuery datatable
- How to remove no data available in table from datatable in jQuery
- How to Rename “show XX entries” dropdown in DataTables
Categories
Popular Posts
Portal HTML Bootstrap
Nov 13, 2024
Freedash bootstrap lite
Nov 13, 2024
Implementing Caching in ASP.NET Core
Dec 14, 2024
11 Things You Didn't Know About Cloudflare
Dec 19, 2024