View Full Version : editorgrid date

23 Sep 2009, 1:25 PM
Having an issue with my date field in a editor grid. I can get the format ('y-m-d') to stick after a date is selected, but after you click off the cell it unformats the date?

{header: "Date", sortable: false, dataIndex: 'date', editor: new Ext.form.DateField({format: 'y-m-d'})},

23 Sep 2009, 7:47 PM
Use a dateRenderer (http://www.extjs.com/deploy/dev/docs/?class=Ext.util.Format&member=dateRenderer) for the renderer configuration which formats your date object.

Once you finish picking the date and the DateField is no longer visible, it is up to the grid to render the data appropriately.

What does the definition for the 'date' field look like in your Store reader? Is it of type 'date'

24 Sep 2009, 8:10 PM
It is possible just a bug[ Not a bug 2009-09-25 13:02:25]... Have a look at these pics,

The ColumnModel config about this column is just like nar. The distinction is that I assign a id for the editor:

{header: '????', dataIndex: 'dateProduct', editor:new Ext.form.DateField({format: 'Y-m-d', id:'dateProduct', readOnly : true})},Step1: The data read from server has rendered ok, though we have not give a renderer configuration for the ColumnModel, and on focus the DateField worked well,

Step2: still, when selected a date value,

Step3: but, when click the up row, the eidtgrid will fetch and render the "Tue Sep 15 2009 00:00" not "2009-09-15".

We can see that there is no relation with the "dateRenderer" on this problem, and we can infer that the EditGridPanel didn't fetch the value from DateField editor correctly.

I solve this problem by the way:

var rcd=e.record;
if (e.field == 'dateProduct') {
var sv = Ext.getCmp(e.field).getRawValue();
rcd.set(e.field, sv);
e.cancel = true;
Oh, I need to submit date in json as string "YYYY-MM-DD" instead of a date object.

24 Sep 2009, 8:19 PM
no. as Aaron said, you just need dateRenderer then it should work.

{header: '????', dataIndex: 'dateProduct', editor:new Ext.form.DateField({format: 'Y-m-d', id:'dateProduct', readOnly : true}), renderer: Ext.util.Form.dateRenderer('Y-m-d')},

you need both editor & renederer config for date column. see http://www.extjs.com/deploy/dev/examples/grid/edit-grid.html example.

24 Sep 2009, 8:55 PM
You can test, the way can't play the role of this issue, but now I see something about this issue.

If we want to show "date" in grid must let the "format" bring into correspondence with each other in 3 places: fields in Store, editor in ColumnModel, renderer in ColumnModel.

I checked my code, after editor and renderer assign a format, then just append dateFormat for the 'dateProduct' field, it's OK.

fields in Store: [..,{name:'prdDate',type:'date',dateFormat:'Y-m-d'},...]
{ header: '????', dataIndex: 'dateProduct',
editor:new Ext.form.DateField({format: 'Y-m-d', id:'dateProduct', readOnly : true}),
renderer: Ext.util.Format.dateRenderer('Y-m-d')
This just show, if need submit date as "YYYY-MM-DD" string, still need to fetch the date value yourself.

Thanks. Not a bug!

25 Sep 2009, 6:06 AM
Thanks for the replies guys, this makes perfect sense now.