PDA

View Full Version : Bug: initComponent does not fire when extending Store



tim594
17 Jul 2008, 4:45 PM
Maybe this is a feature, not a bug, but i searched around for it to no avail...

This code WORKS:


bs = Ext.extend(Ext.Window, {
initComponent: function() {
alert('initComponent!');
Ext.apply(this, {});
bs.superclass.initComponent.apply(this, arguments);
}
});
x = new bs();



BUT this code DOESNT WORK (alert doesnt work):


bs = Ext.extend(Ext.data.Store, {
initComponent: function() {
alert('initComponent!');
Ext.apply(this, {});
bs.superclass.initComponent.apply(this, arguments);
}
});
x = new bs();


The only difference is extending a different class...
Why doesnt it work?


The reason I need it, is because I am extending a GridPanel in a custom class,
and the GridPanel requires a store... so I would like to be able to go:

store: new myApplication.myCustomStore()

instead of having to initialize a custom store first, before defining my extended GridPanel...


myCustomStore=new Ext.data.Store({ ... });
//...now define extended GridPanel
...
store: myCustomStore
...

evant
17 Jul 2008, 5:14 PM
This isn't a bug.

The store isn't a component. As such, it doesn't have an initComponent method.

hendricd
17 Jul 2008, 5:14 PM
@tim594 -- A data.Store is not a renderable component, does not inherit from Ext.Component, thus will not have an initComponent method to override.

hendricd
17 Jul 2008, 5:16 PM
evant === so quick.

evant
17 Jul 2008, 5:32 PM
For extending non-component classes, I generally use:



MyClass = Ext.extend(Ext.data.Store,
{
constructor: function(config)
{
//modify config in some way
MyClass.superclass.constructor.call(this, config);
}
}
);

tim594
17 Jul 2008, 6:35 PM
awesome, exactly what i was looking for.... thanks.