PDA

View Full Version : Combobox remembers previously selected value



nocturn
19 Mar 2012, 2:03 PM
Hi
I have a combobox placed in Ext.Window. Code responsible for creating a combo looks this way


var combo = Ext.create('Ext.form.field.ComboBox', {
name: 'Id',
editable : true,
typeAhead : true,
forceSelection : true,
disableKeyFilter : true,
triggerAction : 'all',
mode : 'local',
valueField: 'Id',
store: me.store,
displayField: 'firstName',
valueNotFoundText: 'Nothing found'
});




Ext.define (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-define)('User',{
extend:'Ext.data.Model (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model)',
fields:[
{name: 'Id', type: 'int'},
{name:'firstName', type:'string'},
{name:'lastName', type:'string'},
{name:'age', type:'int'},
{name:'eyeColor', type:'string'}
]});



var data ={
users:[
{ id:1,name:'Ed Spencer', phoneNumber:'555 1234'},
{ id:2,name:'Abe Elias', phoneNumber:'666 1234'}]
};
var store =Ext.create (http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-create)('Ext.data.Store (http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store)',{
autoLoad:true,
model:'User',
data : data,
proxy:{ type:'memory',
reader:{
type:'json',
root:'users'}
}
});

The problem is that, it seems that combobox remembers the previously selected value. If I open a window and select a value in combobox, this value is remembered if I open a window next time.Despite the fact that I do not set selected value of combobox, the selected value somehow automagically is set. Could somebody tell me what is going on ?

vietits
19 Mar 2012, 3:53 PM
That maybe due to the combobox instance is created one time and is re-used many times. I'am not sure about this without looking at your code. Then try to call <combobox>.reset() method before opening the window.

nocturn
19 Mar 2012, 11:13 PM
Theoretically combobox is created everytime I opened a window. Unfortunatelly <combobox>.reset() didn't do the trick. The value still is somehow selected

Romick
20 Mar 2012, 12:43 AM
Can you give us a peace of code where your window and combo creates? I am sure it created only ones.

Cougar84
24 May 2012, 3:52 AM
I've the same problem ... how can we fix that?

Farish
24 May 2012, 4:39 AM
try the clearValue() method of combobox.

Cougar84
24 May 2012, 4:49 AM
No way ...

Cougar84
24 May 2012, 6:15 AM
PROBLEM SOLVED!!!!!!!!!!

The problem is not the combo, but of the store!!
This because when you type in the combo a filter is applied to the store and never cleaned ...

When you load a new form clean filters of every store binded to the combos!!!!!!!!!!!


combo.getStore().clearFilter(false);


Bye!
Marco