Metrics
0
Watch 2.6k Star 5k Fork 2.5k

ThinkGem / JeeSite 4.xJavaAGPL-3.0

如何在表中通过header的形式,修改日期格式

Closed
搬砖工  Created at

该问题是怎么引起的?

重现步骤

我新建了一个菜单,在下方的表中有创建时间等,基于数据库的考虑,我采用的是int型存储数据,如何在datagrid中修改日期的格式,

报错信息

total 3 participants

Comments (3)

jeesite小白 2019-04-10 19:58

我存的是date类型的,然后是这么处理的
{header:'${text('付款截止日期
Due Date')}', name:'payDeadline', width:120,
formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d'},
editable:true, edittype:'text', editoptions:{'class':'form-control Wdate required', 'readonly':'true',
dataInit: function(element){ $(element).on('focus', function(){
WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});
});
}}
},

getMyHeart 2019-04-10 20:03

{header:'${text("")}', name:'snCode', index:'a.sn_code', width:250, align:"center", frozen:true,formatter:currencyFmatter},

currencyFmatter是js的function ,写在dataGrid初始化之前

	function currencyFmatter(cellvalue, options, rowObject) {
		console.log(cellvalue);
		console.log(options);
		console.log(rowObject);
		var newValeu = "";
		return newValeu;
	}
搬砖工 2019-04-18 11:49

Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, // month
"d+": this.getDate(), // day
"h+": this.getHours(), // hour
"m+": this.getMinutes(), // minute
"s+": this.getSeconds(), // second
"q+": Math.floor((this.getMonth() + 3) / 3), // quarter
"S": this.getMilliseconds()
// millisecond
}
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "")
.substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
return format;
}

function formatDatebox(value) {
value=value*1000;
if (value == null || value == '') {
return '';
}
var dt;
if (value instanceof Date) {
dt = value;
} else {
dt = new Date(value);
}

return dt.format("yyyy年MM月dd日hh时mm分");

}

在datagrid格式化之前,定义这两个方法,然后在formatter中调用

Sign in and comment

Assignee
Labels
Not set
Project
Milestone
Branch
Scheduled start
Not set
Scheduled end
Not set
Top level
Priority

Help Search