Default multi-column sorting AND priority

Default multi-column sorting AND priority

CatCat Posts: 18Questions: 8Answers: 0

This question is two-fold, I wasn't sure whether I should make two seperate threads or combine them into one, apologies if I got it wrong...

I'm relatively new to webdevelopment, I have html experience but very little on php and mysql, I'm hope there's a simple/easy solution to my little problems here...

First of all, following the example here; http://datatables.net/examples/server_side/simple.html
by default the table sorts the data according to first_name, and one of the main reasons why I chose DataTables for my datasorting needs is that by holding shift you can sort by several columns, however, how do you change the default sorting to be the several columns which you want?

Secondly, how do you prioritise which columns you want the data to be sorted according to first? Currently, as far as I can see it prioritises columns in order from the left to the right, in other words if several entries have the same first_name it will sort those according to last_name only secondarily. How would you, for example, prioritise salary sorting, then position and lastly first_name?

If it helps, I'll make an example of what I'm doing; users of my website can submit database entries which others can vote high or low for, resulting in an integer "rating" value. This value is displayed as part of search results sorted by DataTables, which is no problem, however the results also shows post view counts (among some other things that will need priority) which is also an integer value. I need to prioritise the rating column (and a few other columns) before the view count column (while sorting by both columns), is there any way to do this without having to put them accordingly from left to right? Like maybe changing their load order somewhere in the code while leaving the desired order in the resulting html or something?

Many thanks in advance if anyone is able to help me resolve this :)

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.