Pos*_*ing 5 datatables jquery-datatables
我正在使用datatables.net jquery插件并通过asp.net mvc4填充数据.
我的一个列是日期格式.我有兴趣更改它的显示格式,但不会将列的类型从日期更改为字符串.
I'm currently using default initialization:
$('#data-table').dataTable();
Run Code Online (Sandbox Code Playgroud)
My 4th column is a date "Created Date" and is currently displayed as "7/07/2013 9:38:11 p.m." I would like it to be displayed as either "7/07/2013" or "7 Jul 2013".
I thought this was a relatively easy task but haven't been able to find the answer I'm after.
I'd like to avoid additional plugins if possible. Is there a simple way that I'm missing?
Pos*_*ing 15
这就是我想出的.使用它呈现的方式我可以操纵日期显示的方式,无论如何我想要的.
$('#data-table').dataTable({
"aoColumnDefs": [
{
"aTargets": [0],
"bSearchable": false,
"sType": 'date',
"fnRender": function ( oObj ) {
var javascriptDate = new Date(oObj.aData[0]);
javascriptDate = javascriptDate.getDate()+"/"+(javascriptDate.getMonth()+1)+"/"+javascriptDate.getFullYear();
return "<div class='date'>"+javascriptDate+"<div>";
}
}
]
});
Run Code Online (Sandbox Code Playgroud)
我希望这对其他人有用......