我使用 date-euro 插件对日期列进行正确排序。排序工作正常,但是当我添加 sType 参数时,分页会在初始化时中断。当我单击 numberofelement 下拉菜单或下一个按钮时,分页工作。prettydaterender 函数将日期从 2012-10-24 14:00 转换为 24/10/2012 14:00 你能帮我吗?
$.extend( $.fn.dataTableExt.oSort, {
"date-euro-pre": function ( a ) {
if ($.trim(a) != '') {
var frDatea = $.trim(a).split(' ');
var frTimea = frDatea[1].split(':');
var frDatea2 = frDatea[0].split('/');
var x = (frDatea2[2] + frDatea2[1] + frDatea2[0] + frTimea[0] + frTimea[1] + frTimea[2]) * 1;
} else {
var x = 10000000000000; // = l'an 1000 ...
}
return x;
},
"date-euro-asc": function ( a, b ) {
return a - b;
},
"date-euro-desc": function ( a, b ) {
return b - a;
}
} );
table.dataTable({
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
'aaSorting': [[3, 'desc']],
'aoColumns': [null,null,null,{
// 14:43 24/10/2012
'fnRender': prettyDateRender,
'sType': 'date-euro-desc'
}]
});