PHPを使用してテーブルを作成しました& DatatablesプラグインでMySQLを作成しましたが、DD.MM.YYYYで列を並べ替えようとしています。フォーマットはそれが私がそれを望むように動作しないようだ。最初の番号だけを使ってソートしています。 は、ここに私のコードここ(DD.MM.YYYY。)形式のデータ型の並べ替え
$(document).ready(function() {
var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
var datum = day + "." + month + "." + year + ".";
var doc = day + month + year;
$(document).ready(function() {
$.fn.dataTable.moment('DD.MM.YYYY.');
$('#pogled_ispu').removeAttr('width').DataTable({
dom: 'Bfrtip',
scrollY: "500px",
scrollX: true,
scrollCollapse: true,
paging: false,
select: true,
columnDefs: [{
width: 10,
targets: 8
}],
fixedColumns: {
leftColumns: 0
},
buttons: [
'colvis',
'pageLength', {
extend: 'excelHtml5',
text: '<i class="fa fa-file-excel-o"></i>',
titleAttr: 'Preuzimanje u excel formatu',
title: 'Tablični prikaz_' + datum,
exportOptions: {
columns: ':visible'
}
}, {
extend: 'pdfHtml5',
orientation: 'landscape',
text: '<i class="fa fa-file-pdf-o"></i>',
titleAttr: 'Preuzimanje u PDF formatu',
title: 'Prostorno planska dokumentacija',
message: 'Prostorno planska dokumentacija ' + datum,
pageSize: 'A3'
}
],
language: {
"url": "js/Croatian.json",
buttons: {
colvis: '<i class="fa fa-eye"></i>',
pageLength: 'Broj redova'
}
}
});
});
});
そしてここでは、日付時刻の順序のためのプラグインです:
$.fn.dataTable.moment = function (format, locale) {
var types = $.fn.dataTable.ext.type;
// Add type detection
types.detect.unshift(function (d) {
return moment(d, format, locale, true).isValid() ?
'moment-'+format :
null;
});
// Add sorting method - use an integer for the sorting
types.order[ 'moment-'+format+'-pre' ] = function (d) {
return moment(d, format, locale, true).unix();
};
};
は、それが(DD.MM.で問題となっていますYYYY。)形式。私は最後のドットを省略すべきですか?
を私は、それは確かに問題ではないあなたがデータテーブル –