Use default sType if sType function not found
Use default sType if sType function not found
I extend the datatable with custom sort function like
$.extend( $.fn.dataTableExt.oSort, {
"custom-sort-asc": function(a) {}
};
and to use it I define it in aoColumnDefs like
"aoColumnDefs":[
{"mDataProp": "x", "aTargets":[0], "sType":"custom-sort-asc"}
]
Everything works if I use the right name. But I want to allow also a false name because the name is dynamic and could be anything. If it was not found the default sort should be used like
if($.fn.dataTableExt.oSort[sType + '-asc'] == undefined || $.fn.dataTableExt.oSort[sType + '-desc'] == undefined) {
sType = 'html';
}
I do not want to change the datatable origin code but to extend it with that behaviour.
All I want is to change the aaSorting/sType before performing the sort or to use a default sType instead to prevent exceptions like
TypeError: oSort[(("string" + "-") + aaSort[k][1])] is not a function
The init and sort events are after the perfoming. So how can I accomplish this behaviour?