Datatable sorting with all things excluding with Dates. Only sort with date(days) without considering their months. I have dates in (DD-MM-YYYY) formats which was coming dynamically from database. But some of the dates were coming between another month also.
I have used Jquery (jquery-3.3.1.js) and Datatable (datatables_1.10.19.js)
$(document).ready(function (){
var rows_selected = [];
var bookid_value = [];
var table = $('#example').DataTable({
"language": {
"search": ' ',
"searchPlaceholder": "Search",
},
lengthChange: false,
"scrollY": "1000px",
"scrollCollapse": true,
"paging": false,
'columnDefs': [{
'targets': 1,
'searchable': true,
'orderable': false,
'width': '1%',
'bSort': true,
"type": 'date'
}],
'order': [[1, 'asc']],
'rowCallback': function(row, data, dataIndex){
var rowId = data[0];
if($.inArray(rowId, rows_selected) !== -1){
$(row).find('input[type="checkbox"]').prop('checked', true);
$(row).addClass('selected');
}
}
});
});
Output : (After Sorting)
31-08-2019
31-07-2019
31-08-2019
25-07-2019
31-08-2019
08-07-2019
31-08-2019
04-07-2019
31-08-2019
10-07-2019
10-07-2019
13-07-2019
15-07-2019
31-08-2019
31-08-2019