Creating custom sort filter

Creating custom sort filter

meetinmeetin Posts: 4Questions: 3Answers: 0

Hi,

I've come across many tutorials but none is similar to my case. I'm trying to fire sort outside of dataTables:

Code looks something like this:
//init
window.table = $('.table').dataTables();
//call sort from the custom dropdown
window.table.fnSort([[$("#tableSort option:selected").val(), 'desc']]);

So I get by which parameter to sort. The problem now is that the default functionality of fnSort is not enough for me as I'm trying to sort a date, and some rows don't have a date but have "-" instead.

So I'd like to push those with "-" character to the bottom of results, something like this:

loopThroughRows -> if(row == "-") { skip it and put it on the end }

Help would be much appreciated. How can I create a custom function to call the same was as fnSort?

This discussion has been closed.