PDA

View Full Version : Value of timefield not directly shown on drop down



hvtilborg
15 Apr 2012, 11:26 PM
The following JSfiddle describes my problem exactly: http://jsfiddle.net/2uDc9/

You see that the value of 10am is selected correctly in the form. Now click the drop down of the timefield. The value 10am is selected, however, the dropdown list is positioned at the start of the list.

What am I missing? I.e. is there a way so that the dropdown list will be positioned around the currently selected value?

scottmartin
16 Apr 2012, 9:11 AM
Tray adding the properties:

minValue: '6:00 AM',
maxValue: '8:00 PM',

Regards,
Scott.

hvtilborg
16 Apr 2012, 9:22 AM
That doesn't change anything, only the number of choices is more limited...

What is going wrong is this: when you click to open the dropdown list, you don't see - for example: 9:00, 9:15, ..., 11:15, 11:30. Or, when the value is 6pm: 17:30, 17:45, ..., 18:45, 19:00. You'll just end up in the top of the list 6am in the case when Scott's options are applied.

I.e., when you have a regular HTML <select> and an option is selected, whenever the dropdown is opened, the selected value is selected, no matter how long the list is, you'll see the right option selected.

scottmartin
16 Apr 2012, 10:37 AM
the following works for me:




var form = Ext.create('Ext.form.Panel', {
items: [{
xtype: 'timefield',
name: 'time',
renderTo: Ext.getBody(),
step: 15,
listeners: {
change: function(field, newv, oldv) {
console.log(field);
console.log(newv);
console.log(oldv);
}
}
}]
});

form.getForm().setValues({'time': '10:00 AM'});
//form.getForm().setValues({'time': '10am'});


34089

Regards,
Scott.

hvtilborg
16 Apr 2012, 10:26 PM
Hi Scott, when I visit http://jsfiddle.net/3AFNE/ (with Chrome 18.0.1025.162 m, Windows 7), this is what I get...
34102

scottmartin
17 Apr 2012, 4:39 AM
I think I see the problem.

There is problem in 4.07. I was using 4.1RC3. Fiddle also uses 4.07. Please try 4.1 and it should work.

Thanks for correcting my renderTo mistake.

Regards,
Scott.

hvtilborg
17 Apr 2012, 4:41 AM
Are there many changes going from 4.0.7 to 4.1? Since our (big) project is entirely written in 4.0.7, and huge changes would not be desirable at this stage :).

scottmartin
17 Apr 2012, 5:58 AM
I will have to ask around to see if this workaround for this issue. My initial search did not return a result.

Scott.

hvtilborg
22 Apr 2012, 10:20 PM
Hi Scott, have you asked around yet?

scottmartin
23 Apr 2012, 5:36 AM
Sorry for the delay. The code that selects the value was located, but there were additional changes to the picker in 4.1 that are not compatible with 4.07 picker. My initial override was able to selected the data as expected, but there were numerous error in the picker itself. If you want to investigate this further, please have a look at:

// changes in 4.1 vs 4.07
Ext.form.field.Time :: onExpand
Ext.form.field.Time :: syncSelection

Please note that other functions such as Date.isEqual from 4.1 were required for the updated code.

Regards,
Scott.