Hybrid 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; } } });
-
15 Dec 2011 10:13 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Thank you for the report.
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.
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