Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling sorting in datatables not functioning

Here is the code i am using

oTable = $('#example').dataTable({                 "bSort": false,                 "bStateSave":true,                 "aoColumns": [                     { "bSortable": false },                    { "bSortable": false },                    { "bSortable": false } ]              }); 

The problem i'm having is that the table starts off blank and its populated by user input. Once the user starts to input things into the table, it sorts them by product ID. I'm trying to remove this sorting so that it just lists them as they are input.

EDIT: I have come to the conclusion that NONE of my initialization settings are working. I believe it has to do with the fnAddRow when the table is empty except for headers.

EDIT2: I've isolated it down to the fnAddData. When I initialize the table with trash data everything is formatted as its supposed to be but then once i use the fnAddData, it removes all formating

like image 270
aport002 Avatar asked Dec 28 '11 22:12

aport002


People also ask

How do you stop sorting in a data table?

Specify column names in columns option. Use columnDefs option to remove sorting from a column. Pass column index in targets within [] (Indexing starting from 0) and set orderable to false .

How do you disable sorting of only one column in a data table?

But if you want to disable ordering, search or visibility for specific column then you can use columnDefs. columnDefs provide to set parameter allows you to assign specific options to columns in data tables.

What does DataTable destroy do?

function destroy( [ remove ] )Restore the tables in the current context to its original state in the DOM by removing all of DataTables enhancements, alterations to the DOM structure of the table and event listeners.

What is FixedColumns in DataTables?

FixedColumns provides the option to freeze one or more columns to the left or right of a horizontally scrolling DataTable. This allows information in the fixed columns to remain visible even when scrolling through the data set. This can be particularly useful if you wish to show a large number of columns.


2 Answers

Try this:

$(document).ready( function () {$('#example').dataTable( {     "bSort": false   } ); }  
like image 117
Alborz Avatar answered Oct 18 '22 22:10

Alborz


try this:

this is to disable initial sort

$(document).ready( function() {   $('#example').dataTable({     "aaSorting": [] }); }) 
like image 29
Daniel Avatar answered Oct 18 '22 21:10

Daniel