Order column with date field
Order column with date field
lucacali87
Posts: 30Questions: 10Answers: 2
Hi, I have a table with date column and I would like to order this column like the other. The problem is that it seems to order only by day, so if I have 27/01/2015 and 15/02/2015 it uses the first as more new.
I'm using moment with this code:
licenseTable = $('#licensesTable').DataTable({
responsive: true,
//disable order and search on column
columnDefs: [
{
targets: [4,5],
orderable: false,
searchable: false,
}
],
//fix problem with responsive table
"autoWidth": false,
"ajax": "table",
"columns": [
{ "data": "user" },
{ "data": "startDate",
"render": function (data) {
return (moment(data).format("DD/MM/YYYY"));
}
},
{ "data": "endDate",
"render": function (data) {
return (moment(data).format("DD/MM/YYYY"));
}
},
{ "data": "counter" },
{ data:null, render: function ( data, type, row ) {
return '<button type="button" class="btn btn-primary" id="updadteLicense" data-toggle="modal"'
+'data-target="#updateLicenseModal">Update</button>'
}
},
{ data:null, render: function ( data, type, row ) {
return '<button type="button" class="btn btn-danger" id="deleteLicense" data-toggle="modal"'
+'data-target="#deleteLicenseModal">Delete</button>'
}
}
],
});
How can I fix this issue? Thanks
This discussion has been closed.
Answers
I resolved with this plugin
https://datatables.net/blog/2014-12-18