Extjs date column format

为君一笑 提交于 2020-01-03 03:26:47

问题


i have date column with datefield editor. The problem is that while im editing column it displays the normal value for example 2013-02-05, but when close editing it displays something like Sat Jul 12 2014 00:00:00 GMT+0300 (FLE Standard Time)

My code:

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

store field:

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

what the reasons could be?

UPDATE

in store it is also saved with wrong format for some reason, that's why it is being displayed in such format, but i don`t now the reason of that.


回答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
    }
}



回答2:


You need to have your store field as a date type, not a string. Because it is currently a string, ExtJS is converting it directly from datefield.getValue().toString(), which is what is giving it that full format your are getting.

Also note that even if you wanted to use a string for type, the word should be entirely lowercase (you currently have String). Check out this link for the valid type params you can use: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Field-cfg-type




回答3:


try giving type in store as Ext.data.Types.DATE i had similar problem by changin the type to Ext.data.Types.DATE solved it



来源:https://stackoverflow.com/questions/18584530/extjs-date-column-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!