PDA

View Full Version : Time field does not scroll to current value



BvG013
16 Jan 2012, 6:23 AM
Hi all,

I noticed that the behaviour of the time field is different than a that of a standard combobox on quit a significant point.
With the combobox, if the selected value is not in the topmost entries, the field scrolls so that the value is visible. This makes it easy to select a value above or below the selected value.

With the time field this does not apply. When you open the dropdown it always starts at the top position (0:00 or the minValue you assigned). So when a user selected 18:30 and wants to change it to 18:45, he/she has to scroll all the way down.

Is there a quick way to fix this inconvenience?

Bas

mitchellsimoens
16 Jan 2012, 11:08 AM
Ext JS 3 or 4?

BvG013
17 Jan 2012, 2:00 AM
Hi Mitchell,

Thanks for your response.
We are on Ext JS 4.0.1, but the same behaviour occurs with the examples on Sencha.com which is 4.0.6.

Hope you can help.

Bas

mitchellsimoens
17 Jan 2012, 6:11 AM
Ok... I have moved this thread to the Ext JS 4 Q&A forum for you. Please post in the appropriate forum.

humilify
13 Feb 2013, 10:47 PM
The syncSelection function in the timefield object compares the date between the picker store and and the date in field name.
If the time field has a dateFormat of 'H:i:s', that is parsed as of today's date.
The picker uses the date based on the initDate [2008,0,1].
The syncSelection function does a straight Ext.Date.isEqual compare, which is madness.
I personally consider this a bug. Sencha should compare the dates based on the format property of the timefield.

Here is a quick fix. Override the initDate of the picker with listConfig.{
xtype: 'timefield',
format: 'H:i:s',
submitFormat: 'H:i:s',
increment: 30,
listConfig: {initDate: Ext.Date.format(Ext.Date.add(new Date(),Ext.Date.MONTH,-1),"Y,n,j").split(",")},
allowBlank: false,
flex: 1
}

voilĂ !