Jason
Jason

Reputation: 35

Update Datepicker in Sencha Touch Form

I have a sencha touch form where one of the fields has an xtype of 'datefpickerfield'

This operates exactly as it should. (i.e. tap the field, date picker pops up, you select the date, it closes and populates the field)

Based on another event in the form (change of a select field) I would like to update the datepicker field in code.

I have managed to do all of this, except being able to find suitable code that actually updates the field. I can update a text field without issue, but not a datepicker field.

What am I doing wrong?

Sorry, I do not have a proper code sample to post, but if anyone could just point me in the right direction here, I would be most grateful.

This is what I have used to update a text field which works, but doesn't for a datepicker field:

var nDate = '13/08/2011';    
Ext.getCmp('SampleTextField').setValue(nDate);

Upvotes: 1

Views: 4221

Answers (2)

user1131062
user1131062

Reputation: 21

datepicker needs a Date object, not a string

Upvotes: 1

Milton
Milton

Reputation: 968

As per value of a datepickerfield is an object with properties for each component (ie. day, month and year), you can programmatically do the following:

Ext.getCmp('SampleTextField').setValue({day: 1, month: 1, year: 2001});

Also, try to avoid getCmp. It very time consuming.

HTH. Milton.

Upvotes: 0

Related Questions