PDA

View Full Version : GridColumn Date showing wrong date



kumar_Rajesh78
2 Jun 2014, 1:18 PM
Dear all,
I am struggling to figure out a problem related to Date.
problem 1) The date returned in the Json is 02/28/10, but when it displays in the grid, it shows it as 02/17/10 which is one less than the returned date.
problem 2) : This date does not work in IE at all, it displays it as NaN/NaN/NaN in date column.
This is how I have defined, Grid, and Store.

Grid:



{ xtype: 'datecolumn',
dataIndex: 'createDate',
header: 'Create Date',
renderer: Ext.util.Format.dateRenderer('m/d/y'),
width: 100
},


Store:

{
xtype: 'datefield',
name: 'createDate',
dateFormat:'m/d/Y'
},


Any help will be highly appreciated.

Scott Mildenberger
2 Jun 2014, 1:45 PM
I was having this issue just last week. I think it is because it is converting the JSON date at a 00:00 time to a date in your time zone. In my case it was making it 6 hours earlier which is the day before. I did get this fixed and I think it was by adding the 'type' line to my model, see below.. This avoided the time zone conversion as I call it. If this doesn't fix it for you then I might be able to look deeper at my code. I was changing a lot of things trying to fix it so not positive what made it work but I think it was by adding the 'type'.


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

kumar_Rajesh78
2 Jun 2014, 3:54 PM
Thanks for the response.
However it is not working for me.
I tried to use the type:'date'. but IE does not display anything now. Its just blank. and the Chrome displays the date of one day before.

Scott Mildenberger
3 Jun 2014, 6:01 AM
The only other things I can see different in my code is that I don't have an xtype in my model and the xtype of my grid column is 'gridcolumn'.

I put my model code in my last post and here is my column definition.


{
xtype: 'gridcolumn',
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
return Ext.util.Format.date(value,'m/d/Y');
},
width: 90,
dataIndex: 'ADDDATE',
text: 'Date'
}




That may be all I can offer for help unfortunately.

kumar_Rajesh78
3 Jun 2014, 10:10 AM
Thanks a lot Scott for trying to help me.
I will try the last thing that you posted and see if it works.

In general, I feel that Extjs4 does not have a great support for Date feature, especially with more restrictive browsers like IE.

Thanks again,
Rajesh

evant
3 Jun 2014, 5:30 PM
This is covered in the docs: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Field-cfg-dateFormat

If you don't specify a dateFormat you're leaving it up to the browser on how to parse it, which differs between implementations.