sort asc on class

sort asc on class

tuurtnt@hotmail.comtuurtnt@hotmail.com Posts: 7Questions: 0Answers: 0
edited September 2010 in General
Is it possible to add a classname (defaultsort) to a TH, so that datatables always sorts on this column?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Something like this should do the trick:

    [code]
    $('#example').dataTable({
    "aaSorting": [[$('#example thead tr th').index($('th.defaultsort')[0]), 'asc']]
    });
    [/code]
    Allan
  • tuurtnt@hotmail.comtuurtnt@hotmail.com Posts: 7Questions: 0Answers: 0
    thanks! is it also possible to do this within:

    this doesn't work...

    [code]
    "aoColumnDefs": [
    {
    "aaSorting": [[$('#DTsortable thead tr th').index($('th.sortdefault')[0]), 'asc']],
    "aTargets": [ 'sortdefault' ]
    }
    ]
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    There is no aaSorting option for a column definition ( http://datatables.net/usage/columns ) - so no that wouldn't work. aaSorting is a general initialisation option, not a column specific one (since it can span multiple columns).

    Allan
  • tuurtnt@hotmail.comtuurtnt@hotmail.com Posts: 7Questions: 0Answers: 0
    ok thanks!
This discussion has been closed.