-
12 Sep 2012 8:13 AM #1
Answered: String Date to ExtJS Date Formatted
Answered: String Date to ExtJS Date Formatted
Hi,
I have a Date field that comes to me as a String in JSON like
I have to show it as a Date with the same format in my Grid column.Code:"09-05-2012 7:33 AM"
(I am converting it to date as grid column does not sort it as Date but String)
How do i do it?
If i do this in my model
i get value like NaN-NaN-0NaN 12:NaN PMCode:{name: 'someDate', type: 'String', convert:function(value, records){ var rcptDate=new Date(value); return Ext.Date.format(rcptDate, 'm-d-Y g:i A'); }}
What am i doing wrong?
Or is it that it cant be converted?
-
Best Answer Posted by droessner
You can define the field in the store as follows:
and then put the following renderer on your grid column:Code:{ name: 'someDate', type: 'date', dateFormat: 'm-d-Y g:i A' }
Code:renderer: Ext.util.Format.dateRenderer('m-d-Y g:i A')
-
12 Sep 2012 9:57 AM #2
You can define the field in the store as follows:
and then put the following renderer on your grid column:Code:{ name: 'someDate', type: 'date', dateFormat: 'm-d-Y g:i A' }
Code:renderer: Ext.util.Format.dateRenderer('m-d-Y g:i A')
-
12 Sep 2012 11:24 AM #3
I would also use the date type for the field as droessner stated, but I would be slightly more lazy and use the datecolumn
-
12 Sep 2012 11:42 PM #4
Thanks droessner,
Exactly what i wanted.
However i will need a little more testing to see if the Sorting works correctly.


Reply With Quote