PDA

View Full Version : DateField IE7/8 setValue not working / problem



joe123
10 Sep 2010, 4:52 AM
Hi,

I'm having a problem with the DateField widget in extjs version 3.2.1

I'm receiving a date from the php backend and try to set that date
by first gettting the datefield and then setting it:

var mydate = '29-06-09'
Ext.getCmp('datefield_id').setValue(date);

or :

Ext.getCmp('datefield_id').setValue(new Date(mydate));

Both strategies work in Chrome, Firefox and Opera but
not in IE7/8.

Does anyone have a clue on what I should do to fix this!?


Thanks alot,

Joe123

Condor
10 Sep 2010, 4:55 AM
Does 29-06-09 match the dateFormat or one of the altFormats of the DateField?

In that case your first example should work (if you change date to mydate - but I assume that is a typo?).

If not, then you need to parse the date yourself, e.g.

var mydate = Date.parseDate('29-06-09', 'd-m-y');
Ext.getCmp('datefield_id').setValue(mydate);

joe123
10 Sep 2010, 5:09 AM
Hi COndor,

Thanks for the fast reply, but I can still not get it to work.
I am having my datefield configured as follows:



xtype:'datefield',
id:'studytemplate_startDate',
format : 'Y-m-d',
fieldLabel: 'Studytemplate start date',
allowBlank: false

And I am using the same format specifier in the parseDate function as in the datefield itself.
I don't get it.

Thanks, Joe123
}

Condor
10 Sep 2010, 5:13 AM
'29-06-09' doesn't match 'Y-m-d'. Does it match one of your altFormats?

joe123
10 Sep 2010, 5:31 AM
Yes, you are right I gave an incorrect example.
But the backend does it right so I receive values like:

'2006-01-23' which is in the right format as far as I know.

It works in all the other browsers but IE is apparently a bit more
sensitive....


Cheers

Condor
10 Sep 2010, 6:11 AM
Does this work in IE?

alert(Date.parseDate('2006-01-23', 'Y-m-d'));

joe123
11 Oct 2010, 2:06 AM
Hi Condor,

The last tip you gave me worked but did not solve the problem.
I finally solved it by changing the order of the assignments to the form.
Yes indeed very weird. So in detail:

- I have tree nodes that get loaded with their attribute values.
- when the user clicks a node the values are assigned to the form one by one.
- if I start with the normal textfield it does not work.
- if I start with the datefield values it does work.

The code is as follows :


Ext.getCmp('startDate').setValue(node.attributes.startDate);
Ext.getCmp('endDate').setValue(node.attributes.endDate);
Ext.getCmp('id').setValue(node.attributes.id);


This works under IE/FF/Opera and Chrome.

Thanks for all the brainstorming and feedback.


Joe123