No sort my first column
No sort my first column

I have a ranking of points
1 - Alex - 400
2 - John - 540
3 - Paul - 200
With order: [ [ 2,'desc']]
I get
2 - John - 540
1 - Alex - 400
3 - Paul - 200
But I don't want the 1st column to be sorted, I want
1 - John - 540
2 - Alex - 400
3 - Paul - 200
Is there a function with datatable? I searched, searched, but I didn't find. orderable : false is not my solution, I think...
This discussion has been closed.
Answers
Found a solution.
https://datatables.net/examples/api/counter_columns.html
But is there better way?
Sounds like you want to start with
order: [ [ 2,'desc']]
to set the rank order. Then use the code in the example you linked to. But that example changes the counter column anytime you sort or search. I think you only want to run it once after the initial sort. In this case move that code insideinitComplete
.However that might not be what you want. If not then please provide more details:
How are the numbers in the first column generated originally? For example how does Alex get
1
?Can you return the data from the server in the order you want, ie, points field order desc?
Not sure if you want the ability to order the table or not (ordering: false). Datatables will display in the order returned if you use something like
order: [],
. You can use the combo oforder: [],
ororder: [ [ 2,'desc']]
andordering: false
to have a static table.You may be interested in the
orderFixed
option.Just some rambling thoughts on things you may want to consider doing.
HTH,
Kevin