PDA

View Full Version : Ext.form.TimeField: selecting a value which is not in the store



phedoreanu
5 Jul 2010, 5:58 AM
Hy,

I have an Ext.form.TimeField with the default increment value of 15 and when it receives focus, it is updated with the current time. (ex. 13:21).

After the current time has been set, using setValue() when I expand the combo, the default selected value is always the first. Ok, I get that, there is no value for 13:21, but is there a way to select a record/index on expand event ?

I've tried all sorts of things :

expand:{scope:this, fn:function(combo) {
var value = combo.getValue();
var store = combo.getStore();

var hourString = value.substring(0, value.lastIndexOf(':'));
hourString += ':00';

var index = store.find('field1', hourString);
var record = store.getAt(index);

if(index > -1){

var nodes = combo.view.getNodes(index, index + 1);
combo.view.select(nodes[0], false, false);

Ext.fly(nodes[0]).addClass(combo.view.selectedClass);

combo.view.selected.add(nodes[0]);
combo.view.last = nodes[0].viewIndex;

combo.view.all.item(index).addClass(combo.view.selectedClass);
}
but the only line that actually does something is the bold one, which adds combo.view.selectedClassclass to my record.
Now when I expand the combo, I've got 2 selected records the first one (ex 00:00) and my custom one.

Is there a way to select a value and scroll down to it without having to use setValue('13:00') and modifying the current time of the TimeField ?

Thanks