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

      0  

    Default Picker does not correctly set value of 0 or false

    Picker does not correctly set value of 0 or false


    REQUIRED INFORMATION


    Ext version tested:
    • TOUCH 2.0 PR3

    Browser versions tested against:
    • Browser independent

    DOCTYPE tested against:
    • DOCTYPE independent

    Description:
    • If you have a picker with numbers (or booleans) as it's value, it won't allow you to set the value 0.

    Steps to reproduce the problem:
    • create a picker eg:
      Code:
                  var hours = [];
                  var minutes = [];
                  for (var i = 0; i < 60; i++) {
                      if (i < 24) {
                          hours.push({
                              text: Ext.util.Format.leftPad(i, 2, '0'),
                              value: i
                          });
                      }
                      minutes.push({
                          text: Ext.util.Format.leftPad(i, 2, '0'),
                          value: i
                      });
                  }
                  var timePicker = Ext.create('Ext.Picker', {
                      slots: [
                          {
                              name: 'hours',
                              title: 'hour',
                              data: hours
                          },
                          {
                              name: 'minutes',
                              title: 'minutes',
                              data: minutes
                          }
                      ]
                  });
    • Open it with timePicker.show();
    • roll the 'minutes' bar to something else then 0
    • click done
    • call timePicker.setValue({hours: 10, minutes: 0})
    • call timePicker.show() again

    The result that was expected:
    • the timepicker showing 10:00

    The result that occurs instead:
    • hours set to 10, but minutes left to the previous hand-rolled state

    Fix:
    The code to fix is in Ext.picker.Slot:
    Code:
        setValue: function(value) {
            //if (!value) {
            if (!Ext.isDefined(value)){
                return;
            }
    
    
            if (!this.rendered) {
                
                this._value = value;
                return;
            }
    
    
            var store = this.getStore(),
                viewItems = this.getViewItems(),
                valueField = this.getValueField(),
                index, item;
    
    
            index = store.find(valueField, value);
            if (index != -1) {
                item = Ext.get(viewItems[index]);
    
    
                this.selectedIndex = index;
                this.scrollToItem(item);
    
    
                this._value = value;
            }
        }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    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


    Thank you for the report.
    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.

Thread Participants: 1

Tags for this Thread