简体   繁体   中英

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. (ie 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);

datepicker needs a Date object, not a string

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM