3

My Data-Tables Initialization Script is

$('#table').DataTable();

I want to disable auto sort of table column

3
  • try "bSortable": false , look this jsfiddle: jsfiddle.net/jhfrench/ptr63fxt Commented Nov 11, 2017 at 4:48
  • thanks for your anwer Commented Nov 11, 2017 at 4:55
  • 2
    The correct answer is order: [] ...This maintain the order capabilities but does not set a default order, which is [[0, 'asc']] ordering the first column ascending. Commented Nov 11, 2017 at 5:09

4 Answers 4

6

Ok,i found the solution

just add data-order = ' ' in your table

<table class="table table-striped table-bordered " id="table"  data-order=''>
Sign up to request clarification or add additional context in comments.

1 Comment

This is actually good answer, sign your answer as a solution. Simple and effective. I have been seaching for this. Edit: This corrupt table sorting property permanently. It is no good for stopping the initial sorting.
1

Set the aaSorting option to an empty array. It will disable initial sorting,

"aaSorting": []

Example :

$('#you_table_id').DataTable({
    "aaSorting": []
});

The aaSorting array should contain an array for each column to be sorted initially containing the column's index and a direction string (asc or desc).

Comments

0

// For updated version

$('#table').dataTable( {
  "ordering": false
} );

// For older version

This is done by setting bSortable to false

$('#table').dataTable({
"bSortable": false 
});

by aoColumnDefs

$('#table').dataTable( {
    "aoColumnDefs": [ 
        { "bSortable": false, "aTargets": [ 0 ] }
    ] } );

by aoColumns

$('#table').dataTable( {
    "aoColumns": [ 
        { "bSortable": false },
        null,
        null,
        null,
        null
    ] } );

Comments

0

Disabling auto-sort with custom pagination icon using Font Awesome

$("#table").dataTable({
    pagingType: "simple",
    ordering: true,
    autoWidth: true,
    language: {
        emptyTable: "No data available in table",
        paginate: {
            previous: '<i class="fa fa-chevron-left"></i>',
            next: '<i class="fa fa-chevron-right"></i>',
        },
        search: "",
        searchPlaceholder: "Search",
        info: "_START_ - _END_ of _TOTAL_",
        infoEmpty: "",
        infoFiltered: "",
    },
    order: [] // Add this to Disable the auto-sorting
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.