Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1341 in a recent build.
  1. #1
    Sencha User
    Join Date
    Sep 2011
    Posts
    22
    Vote Rating
    0
    ron_stahl is on a distinguished road

      0  

    Default 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
    Browser versions tested against:
    • Chrome 16.0.912.63 m Windows
    • Safari on IPad 2
    • Chrome on Droid X
    Description:
    • 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 result that was expected:
    • The date that is displayed on the form is selected by the date picker when it is displayed
    The result that occurs instead:
    • First date in the picker is displayed
    Screenshot or Video:Operating System:
    • Windows 7

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,203
    Vote Rating
    856
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    22
    Vote Rating
    0
    ron_stahl is on a distinguished road

      0  

    Default


    Yes, I have also tried to use the setValue command with the same results.

  4. #4
    Sencha User
    Join Date
    Jun 2010
    Posts
    18
    Vote Rating
    0
    alexwebb2 is on a distinguished road

      0  

    Default


    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:
    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;
        }
    }); 
    And, while it's an unrelated issue, it's also worth noting that the readOnly check (first line) is also missing in PR3.

Thread Participants: 2