Results 1 to 2 of 2

Thread: Picker does not correctly set value of 0 or false

Hybrid View

Previous Post Previous Post   Next Post Next Post
    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
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,317
    Vote Rating
    1291
      0  

    Default

    Thank you for the report.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •