Extjs 4 dateField getValue

百般思念 提交于 2019-12-11 20:33:12

问题


I feel should be easy but still does not work, "toDate.getValue();" does not return Ext.date object. I cannot format date.

Error: format is undefined.

Below is my form field.

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

And on submission of form, i want to format date.

var toDateTime = toDate.getValue();
console.log(toDate.getValue());
toDateTime.setHours( toHour.getValue(), toMinute.getValue(), 0 );
abs.to = toDateTime.format( Date.patterns.JSONdateTime );   <---------------------

回答1:


There are 2 different date type in Extjs 4.

1) Date

2) Ext.Date

method "format" is available to Ext.date and toDateTime is object of Date. following is right syntax.

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



回答2:


You're missing a comma after 'fieldLabel'. Code should be:

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


来源:https://stackoverflow.com/questions/15931863/extjs-4-datefield-getvalue

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