Ordering multiple columns not working, not doing anything

Ordering multiple columns not working, not doing anything

meanratmeanrat Posts: 3Questions: 1Answers: 0

Hi all.

I have six columns. I'd like to sort by the second, and secondary by the fifth. I can achieve this through user input by shift-clicking, but I'd like it preloaded so the user doesn't have to do anything. I am starting very simple with very few code, so I know there's nothing else wrong and interfering with the code. But everything I do does not result into change. It all keeps the same as if it is not working. As if multicolumn ordering is just not working in DataTables. Here's the javascript.

var table = $(\'#datatables_listing\').dataTable({ "columnDefs": [ { "orderData": [ 0, 1 ], "targets": 1 }, { "orderData": 0, "targets": 2 }, { "orderData": [ 2, 3, 4 ], "targets": 3 } ] });

The numbers are a complete random guess. I am first trying to see some changes in what I do so I can learn the way these numbers work. Because they are complete abracadabra to me. Why not just use something like:
{
"order": 1,
"secondaryOrder": 5
}

Hopefully someone can help me. Thanks.

Maarten

Replies

  • kthorngrenkthorngren Posts: 21,449Questions: 26Answers: 4,975

    Use the order option to set the initial table order. The docs have an example of default ordering multiple columns. Also see this example. The columns.orderData option allows for defining one or more columns that will be used to order the clicked column. See the docs for more details.

    Kevin

  • meanratmeanrat Posts: 3Questions: 1Answers: 0

    Late reaction from my part, but thanks for your advice. I've discovered some old deprecated mess in the code I am working in. Also some things wont work anymore when you force your datatables to be handled serverSide but load the data with ajax.

Sign In or Register to comment.