3.9K Star 18.4K Fork 5.3K

卓源软件 / JeeSite 4.x and 5.x

 / 详情

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

已完成
创建于  
2019-04-10 18:00

该问题是怎么引起的?

重现步骤

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

报错信息

评论 (3)

刘昌龄 创建了任务

我存的是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});
});
}}
},

{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;
	}
卓源软件 任务状态待办的 修改为已完成

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中调用

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(3)
Java
1
https://gitee.com/thinkgem/jeesite4.git
git@gitee.com:thinkgem/jeesite4.git
thinkgem
jeesite4
JeeSite 4.x and 5.x

搜索帮助