Threaded View
-
15 Dec 2011 1:00 AM #1
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; } } });
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1273
in
2.0.


Reply With Quote