Question

I'm getting inconstant results with my dates. Sometime they are getting converted to us format. I have the following json

{ "Created":"09/03/12" }

In my grid i have

{
  id: 'Created',
  text: "Created",
  dataIndex: 'Created',
  xtype: 'datecolumn',
  format: 'd/m/y',
  width: 150,
  sortable: true,
  field: {
    xtype: 'datefield',
    allowBlank: false,
    format: 'd/m/y'
  }
},

So i want to display

09/03/12 (9th March) but i'm getting 03/09/12

Était-ce utile?

La solution

Make sure you supply the correct dateFormat for your Created field in your data model, e.g.:

Ext.define('App.model.FrostysModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'IntData',       type: 'int'}, 
        {name: 'StringData',    type: 'string'},
        {name: 'Created',       type: 'date',   dateFormat: 'd/m/y'}
    ]
});

I think 'm/d/y' is the default.

EDIT:

It is also possible that there is something funky in the ExtJS code if adding a dateFormat doesn't work.

Back in 4.02a I remember having to override something to handle a similar problem: any dates that could be months like 01 - 12 were automatically converted to the default format, or something weird like that. I.e 05/01/12 (5 Jan 2012) became 1 May 2012 but a date like 28/01/12 (28 Jan 2012) would not have that problem because 28 could not be a month.

Unfortunately I can't find that override anymore so you might have to do some tracing.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top