datatables plugin logoDataTables is a fantastic jQuery-powered plugin that supercharges your ordinary HTML tables and as such is pretty much my de facto method for presenting tabular data.

I often include special ‘action’ columns in my table where I lump in all my row data manipulating buttons and thus don’t particularly want to allow DataTable’s column sorting option added to those columns. Thankfully disabling the sorting option on specific columns has now become particularly easy, thanks to the aTargets configuration option.

To achieve the column sorting function we make use of the aoColumnDefs configuration option to turn off the bSortable flag, using the aTargets label to control which columns the specified property definition applies to.

In practice:

"aoColumnDefs": [{ 'bSortable': false, 'aTargets': [ 0,7,9 ] }]

Assuming my table has ten columns, this essentially turns off sorting for the first column, last column and the eighth column (remember, the column array is zero-indexed).

Related Link: