0

I have a datefield xtype mentioned in my grid's date column editor, once I select any date from the picker, as long as I don't click outside or press Enter, the date is displayed in the default format i.e. 'd/m/Y' (meaning dd/mm/YYYY). But as soon as I click outside of the cell or press enter it changes to an entire date containing the timestamp as well. How do I not let this happen? I want to keep it in d/m/Y format and don't want time or day to be displayed.

Here is an example of what it becomes once I press enter.

Tue May 28 2013 00:00:00 GMT +0530 (India Standard Time)

I want it to be

28/05/2013 or Tue 28/05/2013

How to do this?

My configuration for the column is given below

editor: {
    xtype: 'datefield',
    anchor: '100%',
    format: 'd/m/Y',
    submitFormat: 'd/m/Y',
    minValue: new Date()
}
Arnav Sengupta
  • 15
  • 5
  • 10

3 Answers3

1

1 Define the date field in your model -

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

2 Use the following in columns config of the grid, in which you are using the date picker -

{header: 'Date', xtype:'datecolumn', width: 200, dataIndex:'date', editor:{xtype: 'datefield', format:'Y/m/d', allowBlank:'fasle'}}
pkz
  • 208
  • 1
  • 4
0

Please refer below code and let me know whether it works!

editor: {
    xtype: 'datefield',
    anchor: '100%',
    format: 'd/m/Y',
    submitFormat: 'd/m/Y',
    minValue: new Date(),
    listeners : {
               render : function(datefield) {
                   // code to convert GMT String to date object
                   datefield.setValue(new Date());
               }
    }
}

Thanks

Hariharan
  • 3,191
  • 4
  • 19
  • 31
0

When you use a date field, it sets a date type on the model.

Use a renderer on the grid cell (assumes the field is of type date):

{
    xtype: 'datecolumn',
    dataIndex: 'myDate',
    text: 'Date',
    format: 'Y-m-d'
}
Evan Trimboli
  • 29,900
  • 6
  • 45
  • 66