JQuery-EasyUI的DataGrid控件显示日期型数据
Posted lone5wolf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JQuery-EasyUI的DataGrid控件显示日期型数据相关的知识,希望对你有一定的参考价值。
1、自定义一个日期转函数,如:
function formatDate(val) {
var year = parseInt(val.year) + 1900;
var month = (parseInt(val.month) + 1);
month = month > 9 ? month : (‘0‘ + month);
var day = parseInt(val.date);
day = day > 9 ? day: (‘0‘ + day);
var hours = parseInt(val.hours);
hours = hours > 9 ? hours : (‘0‘ + hours);
var minutes = parseInt(val.minutes);
minutes = minutes > 9 ? minutes : (‘0‘ + minutes);
var seconds = parseInt(val.seconds);
seconds = seconds > 9 ? seconds : (‘0‘ + seconds);
var datetime = year + ‘-‘ + month + ‘-‘ + date + ‘ ‘ + hours + ‘:‘ + minutes
+ ‘:‘ + seconds;
return datetime;
}
var year = parseInt(val.year) + 1900;
var month = (parseInt(val.month) + 1);
month = month > 9 ? month : (‘0‘ + month);
var day = parseInt(val.date);
day = day > 9 ? day: (‘0‘ + day);
var hours = parseInt(val.hours);
hours = hours > 9 ? hours : (‘0‘ + hours);
var minutes = parseInt(val.minutes);
minutes = minutes > 9 ? minutes : (‘0‘ + minutes);
var seconds = parseInt(val.seconds);
seconds = seconds > 9 ? seconds : (‘0‘ + seconds);
var datetime = year + ‘-‘ + month + ‘-‘ + date + ‘ ‘ + hours + ‘:‘ + minutes
+ ‘:‘ + seconds;
return datetime;
}
2、在DateGrid控件的列中调用该函数:
columns
: [[ {
field : ‘birthday‘,
title : ‘生日‘,
width : 150,
align : ‘center‘,
formatter : function(value, row) {
return formatDatebox(row.birthday);
}
}, {
field : ‘createTime‘,
title : ‘注册时间‘,
width : 150,
align : ‘center‘,
formatter : function(value, row) {
return formatDatebox(row.createTime);
}
}, {
field : ‘department‘,
title : ‘部门‘,
width : 100,
align : ‘center‘,
formatter : function(value, row) {
return row.department.dname;
}
}
field : ‘birthday‘,
title : ‘生日‘,
width : 150,
align : ‘center‘,
formatter : function(value, row) {
return formatDatebox(row.birthday);
}
}, {
field : ‘createTime‘,
title : ‘注册时间‘,
width : 150,
align : ‘center‘,
formatter : function(value, row) {
return formatDatebox(row.createTime);
}
}, {
field : ‘department‘,
title : ‘部门‘,
width : 100,
align : ‘center‘,
formatter : function(value, row) {
return row.department.dname;
}
}
以上是关于JQuery-EasyUI的DataGrid控件显示日期型数据的主要内容,如果未能解决你的问题,请参考以下文章
jquery-easyui的datagrid(树表),复选框怎么半选?
C# .net不同版本中winform控件 dataGrid /DataGrid/DataGridView 有啥区别