PDA

View Full Version : ComboBox.onStoreLoad extension



cerad
14 Feb 2008, 11:15 AM
I probably reinvented the wheel here but it's always been annoying to me that if a combo box is displayed before the store has finished loading then the actual value will be displayed instead of the displayField.

This extension adds a onStoreLoad method which in turn will update the displayed value when the store has finished loading.


Ext.namespace('Ext.mine','Ext.mine.form');
Ext.mine.form.ComboBox = Ext.extend(Ext.form.ComboBox,
{
initComponent : function()
{
Ext.mine.form.ComboBox.superclass.initComponent.call(this);

if (this.store && this.mode == 'local') this.store.on('load', this.onStoreLoad, this);
},
onStoreLoad : function()
{
this.setValue(this.getValue());
}
});
Ext.reg('combo', Ext.mine.form.ComboBox);


The setValue(getValue()) is a bit strange but seems to do the job. And I limited this to local storage since I don't yet understand how remote works.

Critiques?