Table incorrectly sorts on 1st column

Table incorrectly sorts on 1st column

Lone ShepherdLone Shepherd Posts: 11Questions: 0Answers: 0
edited September 2010 in General
I have a table which is initialized with aoColumns and bSortable set to false for the first four rows, however the table always shows up with the first column td having the sorting_1 class applied.

I assume this is some sort of default? I'd prefer when the table is initialized for no sorting or sorting styles to be applied.

Replies

  • anjibmananjibman Posts: 115Questions: 10Answers: 0
    I am guessing you means column.
    For first column to initialized for no sorting you can put
    [code]
    "aoColumns": [
    { "bSortable": false }, //First Column
    ..... //Set for rest of the columns
    ],
    //Set other properties
    [/code]
    More help on http://www.datatables.net/usage/columns
  • Lone ShepherdLone Shepherd Posts: 11Questions: 0Answers: 0
    As I said in the original post, that's exactly what I'm doing.

    Hence, the problem -- it doesn't seem to be working.
  • anjibmananjibman Posts: 115Questions: 10Answers: 0
    Can u post the code to make things clear.
  • Lone ShepherdLone Shepherd Posts: 11Questions: 0Answers: 0
    edited September 2010
    [code]
    oTable = $('#logTable').dataTable({
    'bAutoWidth': false,
    'bFilter': false,
    'bInfo': false,
    'bJQueryUI': true,
    'bPaginate': false,
    'sDom': 't',
    'oLanguage': { 'sEmptyTable': 'Empty table text.' },
    'aoColumns': [
    {'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
    {'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
    {'bSortable': false },
    {'bSortable': false, 'sWidth': '7em' },
    {'sWidth': '4.5em' },
    {'sWidth': '4.5em' },
    {'sWidth': '4.5em' },
    {'sWidth': '4.5em' },
    {'sWidth': '5em'}
    ]
    });
    [/code]

    That's the code to initialize my table. When I view the table, it appears to be sorted by the first column -- the background colors are different, and each td element in the first column has the sorting_1 class applied.
  • anjibmananjibman Posts: 115Questions: 10Answers: 0
    Ok
    You miss closing quote after myclass on line 10. Change to
    [code]
    {'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
    [/code]
    I tried with this and working for me.
  • Lone ShepherdLone Shepherd Posts: 11Questions: 0Answers: 0
    Sorry; that was a typo in the copy/paste.

    I do not get any syntax errors with my actual table; it works fine, other than being sorted by default on column 1.
  • anjibmananjibman Posts: 115Questions: 10Answers: 0
    I put these code and working for me
    [code]



    DataTables example

    @import "demo_page.css";
    @import "demo_table.css";




    $(document).ready(function() {
    oTable = $('#example').dataTable({
    'bAutoWidth': false,
    'bFilter': false,
    'bInfo': false,
    'bJQueryUI': true,
    'bPaginate': false,
    'sDom': 't',
    'oLanguage': { 'sEmptyTable': 'Empty table text.' },
    'aoColumns': [
    {'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
    {'bSortable': false, 'sClass': 'myclass', 'sWidth': '13px' },
    {'bSortable': false },
    {'bSortable': false, 'sWidth': '7em' },
    {'sWidth': '4.5em' }
    ]
    });

    } );








    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade




    Trident
    Internet
    Explorer 4.0
    Win 95+
    4
    X

    ........



    Rendering engine
    Browser
    Platform(s)
    Engine version
    CSS grade







    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The problem will be aaSorting ( http://datatables.net/usage/options#aaSorting ). It default to have DataTables sort on the first column. It's an interesting problem as to what should happen if that column is marked as not sortable - should there be any initial sort, or should it follow aaSorting, and then not allow the user to perform as sort on the column (as it currently does). The immediate solution is to either set aaSorting to an empty array (no sort) or to a different column.

    Regards,
    Allan
This discussion has been closed.