Custom order 1,2,3,4 as 4,2,1,3 for example
Custom order 1,2,3,4 as 4,2,1,3 for example
How would one best approach this ...
I have a column of values 1-14. When I click the sorter for that column I'd like them to be ordered: 1,2,10,6,3,11,7,4,12,8,5,13,9,14.
I have tried replacing the HTML using a createdRow function and while that 'works' it appears to be too late (i.e., the column still sorts 1,2,3,4,...)
I feel like I'm not fully grokking columnRender or Renderers generally.
For reference my data structure is
ajax: {
url: 'data/table_house_info.json',
dataSrc: ''
},
"columns": [
{ "data": "ratingPhrase" },
{ "data": "seatID" },
{ "data": "fullName" },
{ "data": "trump_margin" },
{ "data": "firstName" },
{ "data": "lastName" },
{ "data": "raceRatingID", },
{ "data": "open_seat", },
{ "data": "turnover" }
],
raceRatingID is the data in question and it will ultimately also be used as the sorting target for ratingPhrase.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Wound up doing this ...
No idea if that's best practice but it's working.
Looks like the Dynamic Enum Sorting plugin will do the trick:
http://live.datatables.net/joresiqe/1/edit
This way if you want to change the numeric order you just simply need to change the array sent to the plugin.
Kevin
Yep, this is better. :-)