我想創建一個包含日期和時間字段的面板。麻煩的是當我試圖把它放在另一個面板內時。日期和時間字段不顯示。我究竟做錯了什麼?這是我迄今爲止的面板定義的代碼。擴展故障ExtJS面板
var DateTime = Ext.extend(Ext.Panel, {
id: '',
xtype: 'panel',
fieldLabel: '',
layout: 'table',
dateField : new Ext.form.DateField({
id: 'dateField',
msgTarget: 'under'
}),
timeField: new Ext.form.TimeField({
id: 'timeField',
msgTarget: 'under',
increment: 1
}),
layoutConfig: {
columns: 2
},
initComponent: function() {
Ext.apply(this, {
items: [this.dateField, this.timeField]
});
AppealDateTime.superclass.initComponent.call(this);
},
getValue: function(){
var returnValue = new Date();
var dateValue = this.dateField.getValue();
var timeValue = this.timeField.getValue();
var hours = timeValue != null && timeValue != '' ? timeValue.split(':')[0]: 0;
var minutes = timeValue != null && timeValue != '' ? timeValue.split(':')[1].split(' ')[0]: 0;
returnValue.setDate(dateValue.getDate());
returnValue.setMonth(dateValue.getMonth() + 1);
returnValue.setFullYear(dateValue.getFullYear());
returnValue.setHours(hours);
returnValue.setMinutes(minutes);
returnValue.setSeconds(0);
return returnValue;
},
setValue: function(value)
{
var hours = value.getHours() % 12;
var displayHours = hours - 12;
this.dateField.setValue(value);
this.timeField.setValue(value.getHours() + ":" + value.getMinutes() + " " + hours > 12 ? "PM" : "AM");
}
});
Ext.reg('dateTime', DateTime);