How do you make an Editor column sort by date asc and keep empties below entries with dates?
How do you make an Editor column sort by date asc and keep empties below entries with dates?
The subject says it all. The date column has entries with dates yet to be assigned. If you click the header and sort by asc the empties display above those with dates which is natural sorting. However we wish to see those with dates above tehe empties like:
2025-07-01
2025-07-02
2025-07-02
2025-07-04
2025-07-05
2025-07-10
*** (no date assigned yet)
tried many options with columDefs such as:
{
targets: 7, // replace with your actual column index
type: 'datetime',
render: function (data, type, row) {
return data || ''; // ensures null shows empty
}
},
Tx
Answers
See if the Absolute sorting plugin does what you want.
Kevin
We tried, with the help of chatGPT, and could not get it to solve the sorting need.
What exactly did you try?
Did you try the plugin I linked to?
Please build a simple test case showing some examples of the date data you have with the text used for empty dates. We can then see if the absolute sorting plugin works for your case. And if not offer other suggestions.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
I put together this simple example using your example data with the sorting plugin.
https://live.datatables.net/tulogula/1/edit
When sorting ASC or DESC the
*** (no date assigned yet)
values stay at the bottom.Kevin