Extjs 4 dateField getValue

时间:2013-04-10 16:51:11

标签: extjs4.1 extjs-mvc

我觉得应该很容易,但仍然无效,“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 个答案:

答案 0 :(得分:0)

你在'fieldLabel'之后错过了一个逗号。代码应该是:

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

答案 1 :(得分:0)

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

1)日期

2)Ext.Date

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

abs.to = Ext.Date.format(toDateTime, Date.patterns.JSONdateTime );