change sort icons based on which custom sType asSorting filter/direction is active

change sort icons based on which custom sType asSorting filter/direction is active

agreigagreig Posts: 1Questions: 0Answers: 0
edited January 2013 in DataTables 1.8
I have this code

[code]
$('#ideas_table').dataTable( {
"aoColumns": [
{ "bSortable": false },
{"sType": "yes-no-dash-string", "asSorting": [ "desc", "asc", "dash" ]},
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] },
{ "asSorting": [ "desc", "asc" ] }
],
"fnDrawCallback": function(oSettings) {
if(this.fnSettings().bSorted){
console.log(oSettings);
// HOW DO I DO THIS ????????????????????????????????????????????????????????????????????????????????????
// if custom 'yes-no-dash-string' is active:
// if asSorting direction == 'dash'
// remove 'sorting_asc' or 'sorting_desc' class on the th and then add the 'sorting_dash' class
}
},
"aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
} );
[/code]

and I have this custom sort plugin code that is loaded from a js file:
[code]
jQuery.fn.dataTableExt.oSort['yes-no-dash-string-asc'] = function(a,b) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
};

jQuery.fn.dataTableExt.oSort['yes-no-dash-string-desc'] = function(a,b) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
};

jQuery.fn.dataTableExt.oSort['yes-no-dash-string-dash'] = function(a,b) {
if(a=='-'){return 1}
return -1;
};
[/code]


Everything works but the sort direction icon only toggles between the up and down arrows (accomplished by assigning thesorting_asc and sorting_desc class to the th). I would like to add another sort icon for when the dash sort is active (by assigning the sorting_dash class to the th)
This discussion has been closed.