如何在ExtJS字段中显示时刻JS格式的日期与xtype:'datefield' [英] How to show Moment JS formatted date in ExtJS field with xtype: 'datefield'
本文介绍了如何在ExtJS字段中显示时刻JS格式的日期与xtype:'datefield'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个ExtJS字段:
I have an ExtJS field as:
field = {
xtype : 'datefield',
format : 'Y/m/d',
draggable : true,
allowBlank : true,
pickerAlign : 'tr-br',
getValue : function()
{
return this.getRawValue();
}
};
这工作正常,我在指定格式的字段中获取日期。我希望能够从datepicker中解析日期,然后以特定格式显示日期。我如何做?
This works fine and I get the date in the field in the specified format. I want to be able the parse the date coming in from the datepicker and then display the date in locale specific format. How do I do it?
推荐答案
field = {
xtype: 'datefield',
format: 'Y/m/d',
draggable: true,
allowBlank: true,
pickerAlign: 'tr-br',
isValid : function()
{
return true;
},
setValue : function(value)
{
var valueToSet = "";
if (value)
{
valueToSet = moment(value).lang(lang + "-" + cntry).format('L');
}
this.setRawValue(valueToSet);
},
getValue: function () {
return this.getRawValue();
}
};
这篇关于如何在ExtJS字段中显示时刻JS格式的日期与xtype:'datefield'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文