【问题标题】:Extjs date column formatExtjs 日期列格式
【发布时间】:2013-09-06 05:31:51
【问题描述】:

我有带有日期字段编辑器的日期列。问题是,在即时编辑列时,它会显示正常值,例如 2013-02-05,但是当关闭编辑时,它会显示类似 Sat Jul 12 2014 00:00:00 GMT+0300 (FLE Standard Time)

我的代码:

{
    xtype : 'datecolumn',
    dataIndex : 'depreciationStartPeriod',
    header : 'Depreciation start period',
    sortable : true,
    id : 'depreciationStartPeriod',
    width : 134,
    editor : {
        xtype : 'datefield',
        format: 'Y-m-d H:i:s'
    }
}

存储字段:

{
    name : 'depreciationStartPeriod',
    type : 'String',
    dateFormat: 'c'
}

可能是什么原因?

更新

由于某种原因,它也以错误的格式保存在商店中,这就是它以这种格式显示的原因,但我现在不知道是什么原因。

【问题讨论】:

  • 你介意为此准备一个 jsfiddle 吗?有人可能更愿意真正提供帮助。

标签: javascript date extjs datepicker date-format


【解决方案1】:
{
    xtype : 'datecolumn',
    dataIndex : 'depreciationStartPeriod',
    header : 'Depreciation start period',
    sortable : true,
    id : 'depreciationStartPeriod',
    width : 134,
    format: 'Y-m-d H:i:s', // <------- this way
    editor : {
        xtype : 'datefield',
        format: 'Y-m-d H:i:s',
        submitFormat: 'c'  // <-------------- this way
    }
}

【讨论】:

  • 再次签出。我有同样的问题,我用这种方式解决了。
  • 可能是因为我使用的是 extjs 3.4?不是最新的?因为这对我不起作用
  • 我发现了问题,这是因为我的其他函数在此列中添加了灰色。感谢您的帮助
【解决方案2】:

您需要将您的商店字段设为date 类型,而不是string。因为它目前是一个字符串,所以 ExtJS 直接从 datefield.getValue().toString() 转换它,这就是你得到的完整格式。

还请注意,即使您想将string 用于type,该单词也应该完全小写(您目前有String)。查看此链接以获取您可以使用的有效 type 参数:http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Field-cfg-type

【讨论】:

  • 将其更改为date 格式不会改变任何内容,我得到相同的行为。
【解决方案3】:

尝试在商店中输入类型为 Ext.data.Types.DATE 我有类似的问题,通过将类型更改为 Ext.data.Types.DATE 解决了它

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多