2012-04-27 39 views
1

在我的模型(Ext.data.Model)我有以下特性日期格式4.1发行

{ 
    mapping:'Created', 
    name:'Created', 
    type: 'date', 
    format:'d/m/Y' 
}, 

在我的形式,我有以下领域

    { 
         xtype:'datefield', 
         name:'Created', 
         fieldLabel:' Date', 
         format:'d/m/Y', 
         width: 350 
        }, 

如果我选择在2012年4月1日的选择器“2012年4月1日”中我选择了以下日期:

我在firebug json的帖子“2012-01-04T00:00:00”(1月4日2012)

我如何才能确保正确的区域,通过

回答

1

未来你所需要的额外的属性submitFormat表单字段:

{ 
    xtype:'datefield', 
    name:'Created', 
    fieldLabel:' Date', 
    format:'d/m/Y', 
    width: 350, 
    submitFormat: 'd/m/Y' 
} 
+1

'format'属性适用于4.2 Ext.js – Meredith 2013-07-23 21:17:52

2

在模型中定义Ext.data.Field。 查看API文档,Ext.data.Field没有配置,名为format,但是dateFormat

试试这个

{ 
    name:'Created', 
    type: 'date', 
    dateFormat:'d/m/Y' 
}, 

,你只需要mapping,如果从后端数据有不同的名称,只要你想在模型中使用。

BTW:由于ExtJS的4.1.3也存在着两个新的配置项:dateReadFormatdateWriteFormat定义为读者和作家不同的格式。但是如果你定义了dateFormat这对两者都是一样的。

+1

供读者参考:'dateFormat'属性不在xtype'datefield'中的4.2 Ext.js – Meredith 2013-07-23 21:19:10