bSortable: false not working on first column - 1.10

bSortable: false not working on first column - 1.10

karinekarine Posts: 4Questions: 0Answers: 0
edited December 2013 in Bug reports
I'm testing the upcoming version (1.10) and found some strange behaviour. I have a first column which I don't want to be sorted or searched. I have set my aoColumns like this:
[code]"aoColumns": [{bSearchable: false, bSortable: false},{sType: "html"},{sType: "html"},{sType: "html"},null,null,null][/code]

The first column will still get class sorting_asc. Doing some testing I tried setting the second column to bSortable: false, and that column gets the correct class sorting_disabled, so seems like it's only a problem with the first column.

Using 1.9.4 bSortable is working as I would expect.

Set up a small JSFiddle example: http://jsfiddle.net/karineh/gkTMu/

Replies

  • allanallan Posts: 61,652Questions: 1Answers: 10,094 Site admin
    What is happening is that the aaSorting option is default `[[ 0, 'asc' ]]` so that is the default sort that is being applied to the table - regardless of bSortable. bSortable is a flag for user interaction, you could still sort the column using fnSort if you wanted.

    However, if this behaviour has changed since 1.9.4 then either 1.9.4 was a bug, or this is unintended. I'll dig into it to find out which!

    Allan
  • karinekarine Posts: 4Questions: 0Answers: 0
    Thank you. The column was sorting_disabled in 1.9.4 when setting bSortable to false.

    I've tried setting "aaSorting": [], as I don't want any initial sort, and it's working perfect in my jsfiddle example, but unfortunatly not at all in my working code. Still get sorting_asc on the first column.

    I've tried to remove other datatables plugins and extensions as well to see if the problem could be there, but no luck.

    As a quick fix I think I'll just remove the class after initializing the table.
  • allanallan Posts: 61,652Questions: 1Answers: 10,094 Site admin
    I think I understand what is happening now. In 1.9.4 the column is actually sorted, but the sorting class is not applied to the header cell - example: http://live.datatables.net/irudow/edit#preview .

    That, I would say, is most certainly wrong. Either the column should not be sorted, or it should be sorted and the sorting class applied. DataTables 1.10 takes the second approach. The way the bSortable flag is seen is as an indication of user interaction - so using fnSort you can still sort a column which is makes as bSortable: false.

    A little confusing I know, but the new documentation for 1.10 does state this fact. It is a tradeoff between flexibility and convenience, and I've gone for the flexible approach here.

    Allan
This discussion has been closed.