[英]Show Current Date Time in field in alpaca automatically
I am using alpaca framework. 我正在使用羊驼框架。 I have date time type, when I click on it only I can able to select the DateTime, I want this to be filled automatically with current date time when it gets focus or when page loaded. 我有日期时间类型,当我单击它时只能选择DateTime,我希望当它获得焦点或页面加载时自动用当前日期时间填充它。
Any suggestions please. 有任何建议请。
You can use the "data" object in alpaca config to set the date field default value to current date: 您可以使用羊驼配置中的“数据”对象将日期字段默认值设置为当前日期:
"data": { "myDateField": new Date() // or you can use moment } }
You can also set the date in the postRender function like this: 您还可以像这样在postRender函数中设置日期:
"postRender": function(control) {
var date = control.childrenByPropertyId["date"];
var currentDateTime = moment().format("MM/DD/YYYY HH:mm:ss")
date.setValue(currentDateTime);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.