View Full Version : Ext.data.Field dateFormat in Grid

24 Oct 2012, 9:57 AM
Hi All,
Working on putting a date in a grid.
It appears that if I set the field up like this:

{name: 'mdate', type: 'date'}
It works, but when I add dateFormat like this:

{name: 'mdate', type: 'date', dateFormat: 'd-m-Y'}
The grid column is now blank, it really doesn't matter what the formatting is - if it has it, it doesn't show in the grid.

Column config is :

header : 'Last Modified Date',
dataIndex : 'mdate',
width : 180,
border : true
I don't think it has anything to do with the column or the grid.

Any ideas How I can fix this? I need a specific format in this column.


24 Oct 2012, 10:28 AM
Ext.create("Ext.grid.Panel", {
columns: [
{ text: "Last Modified Date", dataIndex: "mdate", xtype: "datecolumn", format: "d-m-Y" },
// ||
{ header: "Last Modified Date", dataIndex: "mdate", renderer: Ext.util.Format.dateRenderer("d-m-Y") }


24 Oct 2012, 11:14 AM
Thansk Ext_soft, that seemed to do it, but I wonder why it couldn't be done in the store like I have done in the past?

24 Oct 2012, 11:46 AM
model in format 'd-m-Y'
or a column renderer

24 Oct 2012, 12:49 PM
dateFormat is for reading the date from a remote source:

The format string is also used when serializing Date fields for use by Writers.

A format string for the Ext.Date.parse function, or "timestamp" if the value provided by the Reader is a UNIX timestamp, or "time" if the value provided by the Reader is a javascript millisecond timestamp. See Ext.Date.

It is quite important to note that while this config is optional, it will default to using the base JavaScript Date object's parse function if not specified, rather than Ext.Date.parse. This can cause unexpected issues, especially when converting between timezones, or when converting dates that do not have a timezone specified. The behavior of the native Date.parse is implementation-specific, and depending on the value of the date string, it might return the UTC date or the local date. For this reason it is strongly recommended that you always specify an explicit date format when parsing dates.