Open PhiloNL opened 9 years ago
Looks like a bug. Seems like the sorting is done after the ->format()
call is done and is just doing string sorting without any kind of comparison method.
My interim solution is to output all dates as ISO-8601 strings (which are nicely string sortable) and then doing something like this:
$table->setCallbacks('rowCallback', "function(row, data, index) {
_.forEach(data, function(value, index) {
var dt = moment(value, moment.ISO_8601);
if(dt.isValid()) {
$('td:eq(' + index + ')', row).text(dt.format('MM/DD/YYYY'));
}
});
}");
The sorting from a database point of view is not correct (db dates will be sorted yyyy-mm-dd).
It would be interesting to see what the SQL statement was for this sorting, because the dates should be sorted correctly.
@timgws see my comment about how sorting is being done after the column is being formatted. See CollectionEngine::getArray()
, specifically the call to compileArray()
before doInternalOrder()
.
compileArray()
renders the column which, in the case of a DateColumn
formats the DateTime object.
Hi there!
I have a date column, but sorting doesn't seem to be working properly.
Is this a bug or am I doing something wrong?
Thanks!