Ultimate date sort null dates

Ultimate date sort null dates

DanTheManDanTheMan Posts: 5Questions: 0Answers: 0

I've just implemented the moment.js ultimate date sort plugin, which is much easier to use than the old plugins and normally works very well. The problem is that I have a column which has null dates (last login) which so far have appeared as 'Never'.
The column will then be sorted as alphanumeric. The same occurs with a blank <td></td>. The only way I found to sort this out was by using a zero date which formats to 1-Jan-1970 (ok, but not Ideal).
So is there any way that a column can be forced to use date formatting, or that columns with valid dates can prioritize date type sorting over alpha?

Replies

  • DanTheManDanTheMan Posts: 5Questions: 0Answers: 0

    ?

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    So is there any way that a column can be forced to use date formatting

    You can set the columns.type option to the plug-in name created by the moment.js plug-in. However, a better solution will probably be to update the plug-in to accept null and empty data.

    To that end, I've just updated the plug-in to support those options. You can grab the source from github there - I'll release it on the DataTables CDN in the next few weeks.

    Regards,
    Allan

This discussion has been closed.