Date sorting with multiple dates in the column cell?

Date sorting with multiple dates in the column cell?

MrBachChoiMrBachChoi Posts: 2Questions: 1Answers: 0

Example code: https://jsfiddle.net/mrbachchoi/9rxfqv08/1/
Debugger info: https://debug.datatables.net/ahugih

No error messages

I am trying to make my table sortable by date.
However, certain events that my table details occur over a span of days causing them to be separated by a dash.
When I tried the native sorting the table grouped the (date - date) cells at the bottom, without sorting them into the correct spots.
To circumvent this I attempted to utilize Orthogonal Data outlined here: https://datatables.net/examples/ajax/orthogonal-data .
Though I was able to get it to compare the dates based on the sort data I still get the same result once adding the end date for the multi day events.
Is there any way to circumvent this?
Thank you for you help!

Best,
Jonathan

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,663Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Hi Jonathan,

    Here we go.

    The key thing that were causing the issue was { type: "date", targets: [0] }, - you want to avoid using the columns.type option if you can. If the built in type detection doesn't work, then forcing it to be one of the built in types will cause odd things to happen.

    The other thing I would probably suggest is to have a type property for the renderer and point that to the property that you want to use for the type detection - in this case the milliseconds epoch.

    Allan

  • MrBachChoiMrBachChoi Posts: 2Questions: 1Answers: 0

    Thank you very much Allan! Cheers!

This discussion has been closed.