Alex Okrushko
Alex Okrushko

Reputation: 7382

dataTables plugin: how to sort data initially (server-side processing)

I cannot make it to work properly.

I need on initial load to have my table sorted by 0-index column in 'desc'. I've tried:

$(function() {
    ordersTable = $('#orders').dataTable({
        "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
        "sPaginationType": 'full_numbers',
        "bDestroy": true,
        "bProcessing": true,
        "bServerSide": true, 
        "sAjaxSource": "{% url get_orders %}",
        "aoColumnDefs":[
                         {"aTargets":[0], "asSorting": ["decs", "asc"]}
                                 ]
    });

and what it does is sends "sSortDir_0 :'asc'" and displaying "asc" active after that.

How can it make it work? (without faking click on the column to resend the ajax) Thanks

Upvotes: 1

Views: 3098

Answers (1)

Alex Okrushko
Alex Okrushko

Reputation: 7382

Ok, I guess I've found it: aaSorting and aaSortingFixed sets the initial sorting. (reference here)

Upvotes: 1

Related Questions