How to show Moment JS formatted date in ExtJS field with xtype: 'datefield'

穿精又带淫゛_ 提交于 2019-12-11 22:11:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!