-
29 Dec 2011 5:56 PM #1
Datepickerfield is not defaulting to the correct date when user taps into field
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 #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
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 @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
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 services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost 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:
And, while it's an unrelated issue, it's also worth noting that the readOnly check (first line) is also missing in PR3.PHP Code:Ext.define('Overrides.Ext.field.DatePicker', {
override: 'Ext.field.DatePicker',
onMaskTap: function()
{
if (this.getDisabled() || this.getReadOnly())
{
return false;
}
var picker = this.getPicker();
var initialConfig = this.getInitialConfig();
if (!picker)
{
picker = this.applyPicker(initialConfig.picker);
this.updatePicker(picker);
// Don't use the initialConfig for the value - use the actual value
// picker.setValue(initialConfig.value);
picker.setValue(this.getValue());
this._picker = picker;
}
picker.show();
return false;
}
});
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1341
in
2.0.


Reply With Quote