Bug-report (1.10.x) first icon visible even if sorting is turned off

Bug-report (1.10.x) first icon visible even if sorting is turned off

davidkonraddavidkonrad Posts: 13Questions: 4Answers: 0

see fiddle -> http://jsfiddle.net/t5sKk/

Trying to disable sorting for the first column works OK. But the sorting icon is still visible upon initialization, but disappears after the user has sorted once. This is only the case for the first column, disabling sorting on other columns does not show icons upon initialization. Also, this is only the case in 1.10.x, in 1.9.x this behaviour is not seen.

A workaround is to hide the icon manually :

table.dataTable th:first-child  {
    background : none;    
}

check out the demo above, and run with or without the above CSS to reproduce the problem.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Not a bug, just an extra step needed. As the documentation for columns.orderable notes:

    Note that this option only effects the end user's ability to order a column

    So the fact that the default ordering is on the first column means that the first column is ordered by default. If you don't want that use order.

    Allan

  • davidkonraddavidkonrad Posts: 13Questions: 4Answers: 0
    edited July 2014

    Hi Allan!

    Thank you for answering! Yes, it works with

      var dataTable = $('#example').dataTable({  
          aoColumnDefs : [ {  
             orderable : false, aTargets : [ 0 ]  
         }],  
         order: []   
      });
    

    Without using additional CSS. See fiddle -> http://jsfiddle.net/aJFzc/

    NB: skipped syntax hl since it insist on showing all the code on one line.

  • davidkonraddavidkonrad Posts: 13Questions: 4Answers: 0
    edited July 2014

    Hi Allan Jardine,

    Do I dare to suggest, to a future version, that if sorting for the first column is turned off, then the default sorting (or ordering) so will be the #2 column instead? And so on? It is somehow confusing, that sorting by default goes on 1st column, even if sorting is tuned off for this column, and an icon therefore is shown after initialization.

    Not to critisize, awesome job you have done, just a suggestion.

  • allanallan Posts: 63,512Questions: 1Answers: 10,472 Site admin
    Answer ✓

    Yup - its a good suggestion. This question is asked fairly frequently, so it probably is a good idea to change the behaviour.

    Allan

This discussion has been closed.