Initial column sorting not working

Initial column sorting not working

code-connoisseurcode-connoisseur Posts: 19Questions: 5Answers: 1

In my datatables I can sort by a specific column on initialization by using the code below.

jQuery(document).ready(function($) { var dataTable = $('#contracts-datatable').DataTable({ bLengthChange: false, "pageLength": 10, "pagingType": "simple", "order": [[ 9, "asc" ]], // <<--- Sorting by column 9

What I'd like to do is sort by column 10 first then sort the data by column 9.

On my website when I sort like this it arranges data more efficiently - how can I run this on initialization of my dataTables?

I tried..

jQuery(document).ready(function($) { var dataTable = $('#contracts-datatable').DataTable({ bLengthChange: false, "pageLength": 10, "pagingType": "simple", "order": [[ 10, "asc" ], [ 9, "asc"]],

http://mobilereactor.co.uk/shop/mobile-phones/apple-iphone-5c-8gb-white-deals/

But it doesn't work. These are also hidden columns if that makes any difference.

What should happen with this column sort is I should end up with all the initial cost (free) mobiles on the first page and they should be ordered by their monthly price ascending.

I have attached a screenshot of desired result but I can't seem to make it work.

http://pasteboard.co/1DJu6Muk.png

Answers

This discussion has been closed.