0
dtTable = $("table.tablesorter").DataTable({
    bDestroy: true,
    bSort: false,
    bFilter: false,
    bLengthChange: true,
    "aLengthMenu": [
               [5, 15, 25, 50, -1],
               [5, 15, 25, 50, "All"] // change per page values here
    ],
    "iDisplayLength": recordsPerPage,
    "sDom": "t<'row-fluid'<'m-wrap span3 customTableInfo'i><'m-wrap span4'p><'m-wrap span5 customTablePagingStyle'l>>",
    "sPaginationType": "bootstrap",
    "oLanguage": {
        "sEmptyTable": "There are no records to display based on your filters.",
        "sLengthMenu": "_MENU_ records per page",
        "oPaginate": {
            "sPrevious": "Prev",
            "sNext": "Next"
        }

    },
});

I have this code to apply DataTable on each $("table.tablesorter") in my project.

Now my client want to turn on the sorting. Additionaly he want to have new rows shown and few not. Is there any way after turning bSort: true i can add class to the column that turns sorting off for that column only?

Edit: You can disable by using the no-sort class on your ,

and use this initialization code:

// Disable sorting on the no-sort class
"aoColumnDefs" : [ {
    "bSortable" : false,
    "aTargets" : [ "no-sort" ]
} ]

I have a new question now. When i apply sorting i the css background of the sorted <th> is lost while for non-sorted remains same. I want to retain the formating of the sorted columns. Adding the below option do not work.

bSortClasses: false,

Edit 2:

I found that

table.table thead .sorting {
background: url('images/sort_both.png') no-repeat center right;
}

Is overriding my background-color defined here.

table-advance thead tr th {
background-color: #DDD;
font-size: 14px;
font-weight: bold;
color: #666;
}
6
  • possible duplicate of disable a column sorting using datatables of jquery Commented Jul 8, 2014 at 13:34
  • It is NOT a duplicate of the above mentioned question ... Commented Jul 8, 2014 at 13:42
  • Did you try to add CSS styling rules for the classes that the library adds? It is difficult to understand the real issue without seeing an example of the page. Could you create a jsfiddle? Commented Jul 8, 2014 at 14:06
  • No i have alot of scripts can't create jsfiddle. Commented Jul 8, 2014 at 14:15
  • So basically you answered your own question (and provided your solution, well done!), right? Regarding your most recent CSS issue: table-advance should start with a dot and be more specific than the overriding rule, i.e. use .table-advance thead .sorting and add background-image: none; to remove the background image applied through datatables sorting class. Commented Jul 8, 2014 at 14:29

1 Answer 1

0

I was facing same issue and that was resolved by this.

You can try using

"orderClasses": false,
Sign up to request clarification or add additional context in comments.

1 Comment

can you explain a bit more? This is a comment not an answer

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.