PDA

View Full Version : Format Dates in a Editor Grid



sanjshah
12 Oct 2009, 9:27 AM
Hi,

I have an Editor Gird,


I have formatted this so it passes the fields as dd/mm/yyyy to populate the grid, which works fine but when the data back for an update this is converted, which fails in the DB update, how can I force the information being sent to dd/mm/yyyy?



field dateofpurchase
ID 16
task update
value Mon Nov 26 2007 00:00:00 GMT+0000 (GMT Standard Time)





header: 'Purchase Date',
dataIndex: 'purchaseddate',
width: 80,
sortable: true,
format: 'm/d/Y',
editor: new Ext.form.DateField({
allowBlank: false
})
},{


Thanks,

Sanj

14 Oct 2009, 3:36 AM
the data field needs to be setup as 'type : 'date''

sanjshah
16 Oct 2009, 4:22 AM
Thanks for your reply,

I have added the tye as you requested:



header: 'Purchase Date',
dataIndex: 'dateofpurchase',
width: 80,
type: 'date',
sortable: true,
format: 'd/m/Y',
editor: new Ext.form.DateField({
allowBlank: false
})
},{


The dates seems OK after selecting but changes when I click the Save/Update button of the editor bar - I cannot see any other references to the date except the above line the 'roweditor.js file doesn't contain anything specific its just the generic file.

Any ideas?

Thanks,

Sanjay

16 Oct 2009, 4:26 AM
the data field needs to be setup as 'type : 'date'' <--------- data field is the "mapping" setup in the store!

sanjshah
16 Oct 2009, 4:33 AM
Thanks,

I think I am understanding, I have this as the store, so I need to add some format to the 'dateofpurchase', is this correct (format: 'dd/mm/yy')?



var myRecordObj = Ext.data.Record.create([
{name: 'allocationname', mapping: 'allocationname', sortDir: 'ASC', sortType: 'asUCString'},
{name: 'dateofpurchase', mapping: 'dop'},
{name: 'invoicenumber', mapping: 'invoicenumber'},
{name: 'purchasedfrom', mapping: 'purchasedfrom'},
{name: 'itemcost', mapping: 'itemcost'}
]);




<--------- data field is the "mapping" setup in the store!

16 Oct 2009, 4:42 AM
*sigh*~~~~~~


add : type: 'date' to the FIELD mapping for the DATE FIELD!

sanjshah
16 Oct 2009, 5:16 AM
Aplogies Garcia,

This is driving me nuts (I'm usually able to sort these things out but am having a severe mental block!)

I have added the type as requested:




var myRecordObj = Ext.data.Record.create([
{name: 'allocationname', mapping: 'allocationname', sortDir: 'ASC', sortType: 'asUCString'},
{name: 'dateofpurchase', mapping: 'dop', type:'date'},
{name: 'invoicenumber', mapping: 'invoicenumber'},
{name: 'purchasedfrom', mapping: 'purchasedfrom'},
{name: 'itemcost', mapping: 'itemcost'}
]);


.....
header: 'Purchase Date',
dataIndex: 'dateofpurchase',
width: 100,
type: 'date',
sortable: true,
format: 'd/m/Y',
editor: new Ext.form.DateField({
format: 'd/m/Y',
allowBlank: false
})
},{


The response for the store is correct:


({"total":"44","results":[{"assetID": 14,"dop": "30/08/2007" ,"invoicenumber": "aaaaaaaaaa","purchasedfrom":...



But now the grid displays the dates as 'Wed Mar 07 2007 00:00:00 GMT+0000 (GMT Standard Time)'

What am I missing?

16 Oct 2009, 5:20 AM
Read the following API page: http://www.extjs.com/deploy/dev/docs/?class=Ext.data.Field

mystix
16 Oct 2009, 10:35 AM
i've actually answered this a few times before.

check out the following threads in the 2.x/3.x Help forums:
http://www.extjs.com/forum/showthread.php?t=80374
http://www.extjs.com/forum/showthread.php?t=70327