PDA

View Full Version : Unable to set value from record to Datefield



sachinmulange
3 Jan 2014, 7:00 AM
Hello Guys,

I am facing a issue displaying date value in datefield. Below is the brief description of issue

1. Records are listed in a grid
2. By double clicking record it will be opened in edit mode
3. When form is opened most of the fields is loaded with data but the datefield's are always showing blank data even though there is data associated with in record.

Below is date field configuration

{ xtype: 'datefield', fieldLabel: 'Date', name: 'DateEntered' }

Response received from server



DateCompleted

"20140101000000"









as date value is fetched in "20140101000000" this format it is not showing in date field. Here, while saving record I selected 1/1/2014, it is saved as "2014-01-01 00:00:00.000" in database but unable to bind on form load.

Just wanted to show date in proper format when form is opened in edit mode.

Note: not using model to load data. Used default form.load().

Awaiting suggestions on how to fix this.

Thank you.

Sachin

Phantoll
3 Jan 2014, 7:35 AM
Hi,

when you don't use a Model, you can use the Ext.date.parse method to convert a string to a date

http://docs-origin.sencha.com/extjs/4.2.2/#!/api/Ext.Date-method-parse

sachinmulange
3 Jan 2014, 8:03 AM
Hi Phantoll,

Thank you for quick reply.

I tried using parsing as follows

1. Ext.Date.parse("20140101000000", "Y-m-d g:i:s A")
2. Ext.Date.parse("20140101000000", "Y-m-d")

none of these seems to be working as it resulted in "undefined" as output. I directly used "20140101000000" value in parse function which is returned from server.

Thank you.

Sachin

alexander.urban
3 Jan 2014, 9:04 AM
You are not giving the date in format Y-m-d g:i:s A, so why do you expect it to be parsed correctly?Better try Ext.Date.parse("20140101000000", "YmdHis") instead...

sachinmulange
6 Jan 2014, 1:10 AM
Thank you!!

Got the mistake. Also solution suggested by you will do the job.

Sachin