Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove sorting option from DataTables?

I'm using DataTables plugin. I don't want to use the sorting option (to sort the columns in ASC or DESC order) which comes by default on each <thead>. How can I remove that sorting icon?

like image 641
Chankey Pathak Avatar asked May 02 '13 10:05

Chankey Pathak


People also ask

How to turn off sorting in DataTables?

The ability to order data can be disabled using this option. Note that the ability to add or remove sorting of individual columns can be disabled by the columns. orderable option for each column. This parameter is a global option - when disabled, there are no sorting actions applied by DataTables at all.

How do I sort a specific column in a dataTable?

The existing answers are using legacy DataTables syntax. Versions 1.10+ should use the following syntax: $('table'). dataTable({ "pageLength": -1, //display all records "order": [[ 0, "desc" ]] // Sort by first column descending });

What is aaSorting in dataTable in jquery?

The aaSorting parameter is an array of arrays where the first value is the column to sort on, and the second is 'asc' or 'desc' as required (it is a double array for multi-column sorting).


2 Answers

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 }); 
like image 102
Ricardo Rivera Nieves Avatar answered Sep 19 '22 17:09

Ricardo Rivera Nieves


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 ] }     ] });  
like image 22
Jay Rizzi Avatar answered Sep 20 '22 17:09

Jay Rizzi