How to sort select input dates according to date-eu plug-in?
How to sort select input dates according to date-eu plug-in?
Hello,
Based on [Individual column searching (select inputs)] (http://www.datatables.net/examples/api/multi_filter_select.html), I finally succeded to make this code work.
$(document).ready(function() {
var oTable1 = $('#LoA1').dataTable({
"info": true,
"paging": false,
"dom": '<"top"if>',
"columnDefs": [{
"targets": [2, 3, 7],
"orderable": false
}, {
"targets": [4, 5],
"type": 'date-eu'
}, ],
orderCellsTop: true,
initComplete: function() {
var api = this.api();
$('#LoA1 thead tr#forFilters th').each(function(i) {
if (i == 1 || i == 4 || i == 5) {
var column = api.column(i);
var select = $('<select><option value=""></option></select>').appendTo($(this)).on('change', function() {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val());
column.search(val ? '^' + val + '$' : '', true, false).draw();
});
column.data().unique().sort().each(function(d, j) {
select.append('<option value="' + d + '">' + d + '</option>')
});
}
});
}
});
var oFH1 = new $.fn.dataTable.FixedHeader(oTable1, {
"zTop": "0"
});
});
where columns 4 and 5 are date in DD/MM/YYY format which is the reason why I use date-eu plug-in for sorting these columns.
In line 25, I populate the select inputs keeping unique values and sorting them.
column.data().unique().sort().each(function(d, j) {
My question is: How can I sort the content of the select inputs using the rules of date-eu plug-in and not alphabetically as does sort()
?