问题
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