data range filter
data range filter
Im using this example: https://datatables.net/extensions/datetime/examples/integration/datatables.html
What im i doing wrong? the problem is that with my code the calendar appears in two langues, english and spanish, it is in spanish but after a click it turns back to english i only want my code to have the spanish calendar. this is how my code looks like:
<script>
$(document).ready(function() {
new DateTime(document.getElementById('min'), {
i18n: {
previous: 'Précédent',
next: 'Premier',
months: [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
weekdays: [ 'Dom', 'Lun', 'Mar', 'Mier', 'Jue', 'Vie', 'Sab' ]
}
});
new DateTime(document.getElementById('max'), {
i18n: {
previous: 'Précédent',
next: 'Premier',
months: [ 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre' ],
weekdays: [ 'Dom', 'Lun', 'Mar', 'Mier', 'Jue', 'Vie', 'Sab' ]
}
});
});
</script>
<script>
$(document).ready(function() {
var minDate, maxDate;
// Custom filtering function which will search data in column four between two values
$.fn.dataTable.ext.search.push(
function( settings, data, dataIndex ) {
var min = minDate.val();
var max = maxDate.val();
var date = new Date( data[0] );
if (
( min === null && max === null ) ||
( min === null && date <= max ) ||
( min <= date && max === null ) ||
( min <= date && date <= max )
) {
return true;
}
return false;
}
);
// Create date inputs
minDate = new DateTime($('#min'), {
format: ' DD/MM/YYYY'
});
maxDate = new DateTime($('#max'), {
format: 'DD/MM/YYYY'
});
// DataTables initialisation
var table = $('#myTable').DataTable();
// Refilter the table
$('#min, #max').on('change', function () {
table.draw();
});
});
</script>
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
Is this a continuation of this thread? As I said there, please provide a test case,
Colin
okay sorry i forgot that rule, and thanks i have already solve it, i was doing the newDateTime process two times, that is why i was having that trouble