问题
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();
}
};
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?
回答1:
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();
}
};
来源:https://stackoverflow.com/questions/24866745/how-to-show-moment-js-formatted-date-in-extjs-field-with-xtype-datefield