asSorting troubles

asSorting troubles

JohnDTJohnDT Posts: 2Questions: 0Answers: 0
edited December 2013 in DataTables 1.9
Hello,

I'm having trouble with asSorting. When my table is rendered, the default sorting on the first column is still ascending. It's when I click on it that it changes to descending and then locks in and stays with descending. I'd like to load with descending by default. My code is below. If it makes any difference, I'm using the bootstrap styles. Thanks in advance.

[code]
$(document).ready(function() {
$('#procedures').dataTable({
"fnPreDrawCallback": function(oSettings, json) {
$('.dataTables_filter input').addClass('form-control');
$('.dataTables_filter input').css('width', '200px');
$('.dataTables_filter input').attr("placeholder", "Search");
},
"sDom": "<'row'<'col-sm-12'<'pull-left'f>>>rt<'row'<'col-sm-6'i><'col-sm-6'p>><'clear'>",
"aoColumnDefs": [
{"asSorting": ["desc"], "aTargets": [0]},
{"bSortable": false, "aTargets": [-1]},
{"bSearchable": false, "aTargets": [-1]}
],
"oLanguage": {
"sSearch": ""
}
});
});
[/code]

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    You need to also specify aaSorting which is the initial sort applied to the table.

    I know the documentation in this area isn't brilliant. I'm working on improving it!

    Allan
  • JohnDTJohnDT Posts: 2Questions: 0Answers: 0
    That did the trick. Thanks!
This discussion has been closed.