View Full Version : Instance store variable for class extending Combobox

6 Aug 2012, 9:47 AM
Hello Everyone,
I have a Combobox that I am going to use for "Live Search". I would rather not have a globally available store for the combobox but I would like to have an instance variable for the combobox. My question is, what is the best way to create an instance store in a class that extends Combobox. As of now I am going with something like this until told otherwise.

initComponent:function () {
var me = this;
var localStore = Ext.create();

Ext.applyIf(me, {
store: localStore,
displayField: 'title',

Any help is greatly appreciated.

6 Aug 2012, 10:20 AM
See if this works:

Ext.define('myStore', {
extend: 'Ext.data.Store',
alias: 'store.mystore'
//.... the rest of the store config ....

Ext.define('myCombo', {
requires: ['myStore'],
initComponent: function () {
this.store = {
type: 'mystore'
//... any additional component specific store configs
// .... the rest of your initComponent code

6 Aug 2012, 10:29 AM
You could change to:

store: Ext.create()
me.store = localStore


6 Aug 2012, 10:34 AM
I was thinking that the create method didn't create unique instances after reading skirtle's blog article:

6 Aug 2012, 10:44 AM
The difference is the initComponent section that allows you to create in factory mode as well.


6 Aug 2012, 10:46 AM
Right on. Wasn't aware of that distinction. And that's why I browse the forums!

Thx for the tip.

6 Aug 2012, 10:58 AM
Thanks slemmon, I'll try that when I get home tonight. And just to be sure, the 'myStore' is declared in the same class file as the combobox correct ?

And to Scott, do you mind explaining what you mean by 'Factory' mode. I know what a Factory is, but I'm not sure of the implications in this context when referring to the creation of components.