Sorting On Original Column Data
Sorting On Original Column Data
Drum998
Posts: 14Questions: 6Answers: 0
Hi,
I have a datatable where one of the columns contains a date which needs to be sortable. The data stored in the db for this date is a unix timestamp. I am formatting this to something more friendly using a render function and moment.js
My question is how can I make the date column sort using the original unix timestamp rather than the rendered human readable date?
my column definitions look like this:
columns: [
{ data: 'jobId' },
{ data: 'venueId'},
{ data: 'bookingDate', render: function ( data, type, row ) {
var thisDate = moment(data * 1000).format('MMMM Do YYYY');;
return thisDate;
}},
{ data: 'bookingTime',"bSearchable": false},
{ data: 'catalogue', "bSearchable": false},
{ data: 'jobStatus',"bSearchable": false}
],
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I solved this returning two columns from the data source, one for diplaying and one for sorting: