29 Dec 2011 5:56 PM #1
Datepickerfield is not defaulting to the correct date when user taps into field
REQUIRED INFORMATIONExt version tested:
- Sencha Touch 2 PR3
- Chrome 16.0.912.63 m Windows
- Safari on IPad 2
- Chrome on Droid X
- I have a datepickerfield in a fieldset that is contained in a Ext.form.Panel. I am setting the values with data store using the setRecord function. When the view is displayed the correct date is displayed from the store but when the user taps into the field the date picker defaults to the first year and month and day of the date picker. If is set the value in the view using value: new Date() the date picker is set to today's date.
- The date that is displayed on the form is selected by the date picker when it is displayed
- First date in the picker is displayed
- Windows 7
30 Dec 2011 9:56 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
Assuming the field that is getting applied to the date picker field is a date object? Have you tried to just use setValue on the field?Mitchell Simoens @LikelyMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services firstname.lastname@example.org
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.
30 Dec 2011 2:09 PM #3
Yes, I have also tried to use the setValue command with the same results.
11 Jan 2012 8:51 AM #4
Ran into this exact issue yesterday (in PR3) while building a TimePickerField. The problem lies in the onMaskTap function of Ext.field.DatePicker: it's always setting the initial value of the picker with picker.setValue(initialConfig.value). This means that the initial value will only be correct if it is specified in the field's config - which is not usually going to be the case in an MVC application where the controller is taking care of loading values into the view.
This is fixed with the following override:
if (this.getDisabled() || this.getReadOnly())
var picker = this.getPicker();
var initialConfig = this.getInitialConfig();
picker = this.applyPicker(initialConfig.picker);
// Don't use the initialConfig for the value - use the actual value
this._picker = picker;