我新建了一个菜单,在下方的表中有创建时间等,基于数据库的考虑,我采用的是int型存储数据,如何在datagrid中修改日期的格式,
我存的是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中调用
登录 后才可以发表评论