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;
}
Shanker Paudel
  • 740
  • 1
  • 9
  • 21
  • possible duplicate of [disable a column sorting using datatables of jquery](http://stackoverflow.com/questions/3932587/disable-a-column-sorting-using-datatables-of-jquery) – Shanker Paudel Jul 08 '14 at 13:34
  • It is **NOT** a duplicate of the above mentioned question ... – davidkonrad Jul 08 '14 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? – user1595702 Jul 08 '14 at 14:06
  • No i have alot of scripts can't create jsfiddle. – Shanker Paudel Jul 08 '14 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. – SaschaM78 Jul 08 '14 at 14:29
  • I think here you can find some help. http://stackoverflow.com/questions/3932587/disable-a-column-sorting-using-jquery-datatables?rq=1 – Hardik Patel Jun 06 '16 at 11:24

1 Answers1

0

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

You can try using

"orderClasses": false,
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74