PDA

View Full Version : Store empty after selection?



Dirk1
13 May 2011, 11:56 PM
Hi all,

I created an own combotype with a store initially loaded from a PHP Backend. This is the way I implemented it (I need it on several pages so I've chosen that way of realising it):



myCombo = Ext.extend(Ext.form.ComboBox, {
id: 'myCombo',
initComponent: function() {
this.anchor = '100%',
this.store = myStore,
this.mode = 'local',
this.editable = true,
this.displayField = 'NAME',
this.valueField = 'ID',
this.minChars = 3,
this.loadingText = 'Loading',
this.triggerAction: 'all'
}
myCombo.superclass.initComponent.call(this);
}
);
Ext.reg('myCombo', myCombo);




this.myStore = new Ext.data.DirectStore({
api: {
read: myMethod
},
paramHash: true,
autoload: true,
root: 'VALUES',
fields: ['ID', 'NAME'],
listeners: {
'exception': ...
}
});




xtype: 'custom',
customtype: 'myCombo',
id: 'myComboId',
fieldLabel: 'Select',
hideTrigger: true


Now the problem is, that saved values are initially placed into Textfields. E.g. you have chosen "New York" as your home town and save it, the next time you call the page "New York" is set as default into the comboBox. If I now select another value but don't save it and click on another page that uses this combo, the selected values cannot be resolved anymore (this means, if you have chosen "Chicago" on another page the Textfield is empty).

If I use firebug and call Ext.getCmp('myFileId').myStore the store seems to be completely loaded.

Does anyone know why the store seems to be empty after selecting another value? I hope you understood what I mean?!

Thanks and best regards,

Dirk

Dirk1
15 May 2011, 11:22 PM
Hi all,

I found the solution on my own: Setting a 'select'-listener that calls clearFilter method was the solution.

Thanks and best regards,

Dirk