【问题标题】:Datefield Extjs to show years less than 100Datefield Extjs 显示小于 100 的年份
【发布时间】:2018-03-08 14:08:08
【问题描述】:

我有一个日期字段,我需要将默认日期设置为 01-01-0001,但日期字段没有显示/选择小于 100 的日期。如果我选​​择一个日期 01-01-0001 它显示 01-01-1901。而且我没有选择并直接输入 01-01-0001 它在数据库中保存为 01-01-0001 但在显示时显示 12-30-0000

在模型中,我以这种方式使用读写格式。 { type: 'date', name: 'shipDate', dateReadFormat: 'time', dateWriteFormat: 'c' }, Not sure what is wrong. Fiddle example

【问题讨论】:

    标签: extjs extjs5 extjs6 extjs6-classic datefield


    【解决方案1】:

    您的模型定义可以是:

    Ext.define('testmodel', {
        extend: 'Ext.data.Model',
        fields: [
            {
            name:'f_date', 
            type:'date', 
            dateFormat: 'c', 
            dateWriteFormat: 'd-m-Y',
            dateReadFormat: 'd-m-Y'
            }
        ]
    });
    

    日期输入字段定义可以是:

    {
        xtype: 'datefield',
        anchor: '100%',
        fieldLabel: 'To',
        name: 'to_date',
        format: 'd-m-Y'
    }
    

    我不知道你的数据库是什么,但是通过这些设置我可以成功地从 MS SQL Server 读写。

    【讨论】:

    • 当值为空或null时,我们可以设置默认日期为01-01-0001吗?
    • 即使我的是数据库中的 sql,我也可以看到 01-01-0001,但显示时显示的是 12-30-0000
    猜你喜欢
    • 2011-01-11
    • 2011-08-25
    • 2010-12-03
    • 2011-03-05
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多