Setting Column Data Color on Sort
Setting Column Data Color on Sort

Hi All,
I've got the following table where the color is set to red initially, based on the default sort order:
http://live.datatables.net/yohuluco/12/edit
What I'm trying to do is move that color of red to whatever column is clicked on/sorted on. The current code sets red here in the rowCallback function:
$(row).find('td:eq(3)').css('color', '#ac1a2f'); // sets color for total points
What would be the cleanest way to do this?
Thank you,
Ed
This question has an accepted answers - jump to answer
Answers
See this example:
http://live.datatables.net/yohuluco/13/edit
In
rowCallback
you can get an instance of the Datatable API withthis.api()
. Next get the table order. note you can have more than one column being ordered. The example just gets the first in the array. Then usecolumn.index()
with thevisible
parameter to get the visible index to take in consideration the hidden column.All the cells will need to be reset to the default color first then apply the color to the sorted column.
Kevin
Brilliant, thank you Kevin.
Ed