PDA

View Full Version : Having a beforeInitComponent in a superclass



Dumas
20 Jun 2009, 5:16 AM
Hi!

I've a designing question, want to define a basic grid and then extend this one:
in the initComponent function I would like to do
1) some basic stuff which should be in the basic grid
2) then some specific which should be in the extended grid
3) and then call use superclass.onRenderapply() to call the basic grid initComponent and do some other stuff defined in the basic grid
What would be the best implementation? Just writing an function like initStart: function() {...} which is called inside the specific grid initComponent at the top?


thx
Dumas

mjlecomte
20 Jun 2009, 6:14 AM
Sounds like you might want to either override the default grid, or extend it once for you base changes and then extend it again for your additional changes.

Dumas
20 Jun 2009, 6:41 AM
No, thats not what I really want, I'll give you an example with my first idea how to solve the problem:


MyApp.grid.BasicGrid = Ext.extend(Ext.grid.EditorGridPanel, {
initComponentStart:function() {
// do something like e.g.
this.newObject = new Ext.whatever;
}
initComponent:function() {
// do something else
....
// call parent
MyApp.grid.BasicGrid.superclass.initComponent.apply(this, arguments);
}

MyApp.grid.Grid1 = Ext.extend(MyApp.grid.BasicGrid, {
initComponent:function() {
// do first instanzising
MyApp.grid.Grid1.superclass.initComponentStart.apply(this, arguments);

// do something else with already defined stuff
....

// call parent
MyApp.grid.Grid1.superclass.initComponent.apply(this, arguments);
}

// some other implementations for Grid2, grid3, ....

thx
Dumas

Animal
20 Jun 2009, 7:05 AM
We usually call that a "constructor"