0

I have a datatable and have 10 columns in it. I need to sort three columns 2, 3 and 4. The 4th column has two h:outputText, one - the order no. and other being the date. I need to sort by order no. for the 4th column. How could I do this? I have added the below code but it doesn't sort properly.

$('[id$=example]').dataTable({
        "bJQueryUI" : true,
        "iDisplayLength" : 10,
        "bAutoWidth" : false,
        "bRetrieve" : true,
        "bDestroy" : true,
        "aaSorting" : [],
        "bLengthChange": false,
        "aoColumnDefs": [
      { "bSortable": false, "aTargets": [ 0,1,5,6,7,8,9 ] }
   ]
});

Thanks.

2
  • 1
    may this will help you jsfiddle.net/vxshL3ju/1 Commented Nov 27, 2015 at 11:12
  • Show your HTML table with sample data. Consider creating an example on jsFiddle to demonstrate your problem. Commented Nov 27, 2015 at 16:55

1 Answer 1

1

Try this one

$('[id$=example]').dataTable({

                "order": [
                    [2, 'desc']
                ],
});
Sign up to request clarification or add additional context in comments.

1 Comment

It works. Can even order by multiple columns like order: [ [2, 'desc'], [1, 'asc'] ].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.