datatables momentjs sorting issue

datatables momentjs sorting issue

danielviannadanielvianna Posts: 15Questions: 7Answers: 0

Hello Alan,

I am facing an issue when I tried to use moment.js to sort a column.

ideally, we have 3 columns, the middle column is a combination of an image, text, and date.
currently, my solution is to split the middle column into 2 columns, the first part is the image and text and the second part is date.
I was wondering if there is a way to write a momentjs date format to sort
<img src="https://id.cast-soft.com/moa/dist/pic/valid.svg">Valid until Aug. 31, 2020
and
<img src="https://id.cast-soft.com/moa/dist/pic/invalid.svg">Expired on Aug. 31, 2020
based on date order

Thank you,

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765
    Answer ✓

    I suspect the moment sorting plugin doesn't support the extra data. You can use orthogonal data and set the sort type to just the date. Then the moment sorting should work assuming your moment date format is correct.

    Kevin

  • danielviannadanielvianna Posts: 15Questions: 7Answers: 0

    Thank you Kevin, your solution works :)

This discussion has been closed.