PDA

View Full Version : Date column showing up blank in grid



anewbornbunny
15 Jul 2014, 9:45 AM
Hey, I'm trying to get stored dates show up in a column of their own in a grid.

My stored data has the dates formatted similarly as follows:

"date": "2011-09-16T21:11:24 +05:00"

I've played around with the model for the data and figured the date field should be set as something like:

{ name: 'date', type: 'date', dateFormat: 'yyyy-MM-ddThh:mm:ss z' }

But when I try to add the column to my grid like this:

{
text: 'Date',
dataIndex: 'date',
format: 'Y-m-d H:i:s'
}
nothing shows up at all. It just shows the column with no dates or anything in it.

anewbornbunny
15 Jul 2014, 3:21 PM
Eh, turns out I'm just dumb . You know what they say about assuming... :)

As for the solution, I just had to go on the api docs for Date (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Date) (shocking, right?), and create the dateformat to align with how I have it stored.

e.g.

{ name: 'date', type: 'date', dateFormat: 'Y-m-dTH:i:s P' }

Then set the renderer to output the date in a format I wanted.


{
text: 'Date',
dataIndex: 'date',
renderer: function(val) {
return Ext.Date.format(val, 'Y-m-d H:i:s');
}
}