代码之家  ›  专栏  ›  技术社区  ›  extjs user

Extjs 4日期字段getValue

  •  0
  • extjs user  · 技术社区  · 11 年前

    我觉得应该很容易,但仍然不起作用,“toDate.getValue();”不返回Ext.date对象。我无法格式化日期。

    错误:格式未定义。

    下面是我的表单字段。

    var toDate = new Ext.form.DateField(
            {
                fieldLabel: "date"
                value: new Date(), name: "abs-to-date",
                width: 100,
                allowBlank: false
            }
    

    在提交表格时,我想格式化日期。

    var toDateTime = toDate.getValue();
    console.log(toDate.getValue());
    toDateTime.setHours( toHour.getValue(), toMinute.getValue(), 0 );
    abs.to = toDateTime.format( Date.patterns.JSONdateTime );   <---------------------
    
    2 回复  |  直到 11 年前
        1
  •  0
  •   user2135671    11 年前

    Extjs 4中有两种不同的日期类型。

    1) 日期

    2) 外部日期

    方法“format”可用于Ext.date,toDateTime是date的对象。 以下是正确的语法。

    abs.to = Ext.Date.format(toDateTime, Date.patterns.JSONdateTime );
    
        2
  •  0
  •   James    11 年前

    “fieldLabel”后缺少一个逗号。代码应为:

        var toDate = new Ext.form.DateField({
            fieldLabel: "date", //<----------
            value: new Date(),
            name: "abs-to-date",
            width: 100,
            allowBlank: false
        });