我的模型代碼日期通過錯誤4.0.2a MVC
Ext.define('gantt.model.Project', {
extend: 'Ext.data.Model',
fields : [
{ name: 'id', type: 'int', useNull: true, mapping: 'projectid'},
{ name: 'title', type: 'string', mapping: 'projecttitle'},
{ name: 'name', type: 'string', mapping: 'projectname'},
{ name: 'description', type: 'string', mapping: 'projectdesc'},
{ name: 'startdate', type: 'date', mapping: 'startdate', dateFormat :'time'},
{ name: 'enddate', type: 'date', mapping: 'enddate', dateFormat :'time'},
]
});
我的觀點是
Ext.define('gantt.view.projectmgt.projectAdd', {
extend: 'Ext.form.Panel',
alias: 'widget.projectadd',
title: 'New Project Detail Input Window',
width: '50%',
xtype:'fieldset',
title: 'Project Details',
collapsible: true,
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items :[{
fieldLabel: 'Title',
name: 'title',
xtype: 'textfield'
},{
fieldLabel: 'Name',
name: 'name',
xtype: 'textfield'
},{
fieldLabel: 'StartDate',
name: 'startdate',
xtype: 'datefield',
format: 'Y/m/d'
},{
fieldLabel: 'EndDate',
name: 'enddate',
xtype: 'datefield',
format: 'Y/m/d'
}, {
xtype: 'htmleditor',
name: 'description',
fieldLabel: 'Description',
height: 200,
anchor: '100%'
}],
buttons: [{
text: 'Save',
action: 'show-gantt-view'
},{
text: 'Cancel',
action: 'cancel'
}]
});
我的形式面板具有保存按鈕時我點擊它我的控制器執行以下方法
createProjectGanttpanel: function(btn) {
var win = this.getProjectAdd().getForm().getValues();
console.log('PANEL VALUES ARE ::'+win["startdate"]);
record = Ext.create('gantt.model.Project');
record.set(win);
this.getProjectsStore().add(record);
this.getProjectsStore().sync();
}
此方法將值分配給模型,然後存儲將它們保存到我的數據庫。但我有問題,當我選擇它的日期格式打印在控制檯日誌爲'2012/01/31',但是當我看到螢火蟲POST選項卡它顯示startdate傳遞爲'-19800000'和enddate傳遞as'-19800000'
在服務器端,當我看到我的JAVA控制檯時,它顯示我的「startdate」:「1970-01-01T05:30:02」,「enddate」:「1970-01 -01T05:30:02「這是不正確的。由於這個原因,正確的日期不能在我的網格面板中查看。
我在做什麼這裏在我的代碼錯了。幫助我找到問題,以便我可以儘快解決。
我使用extjs 4.0.2a mvc和JAVA作爲我的服務器端技術。
在服務器端,Java Date對象使用日期以毫秒爲單位,而客戶端使用日期以秒爲單位,不是? – 2012-01-30 09:30:13
你可以在設置後記錄「記錄」的外觀嗎?可能是這個'set'方法沒有正確處理它。 – 2012-01-30 09:31:36
我設置日期後,我的記錄看起來像** 1970-01-01 00:00:00 **。問題在於dateformat。選擇日期後,我將**日期作爲** 2012/01/31 **,但在分配給我的模型後,它會變成一些垃圾值,例如** 1970-01-01 00:00:00 ** whichi被髮送給服務器。你有任何想法如何解決這個問題? – 2012-01-30 09:43:48