-
7 Mar 2012 4:00 PM #1
Can I override Store's constructor or component's initComponent()?
Can I override Store's constructor or component's initComponent()?
I just updated my Designer to build 309. Apart for some minor glitches is working and there is the new feature to create override class.
Can I override Store's constructor or component's initComponent()?
I need to populate some store with a list of years like:
But new constructor code isnt invoked...Code:Ext.define('AutoGestion.store.override.Anos', { requires: 'AutoGestion.store.Anos' }, function() { Ext.override(AutoGestion.store.Anos, { constructor : function(cfg) { cfg.data = [{ano: 2007, nombre: '2007'}]; this.callOverridden(cfg); } }); alert("override1"); });
Some example please...
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
7 Mar 2012 7:31 PM #2
This works fine in Sencha Touch 2.0.0. There is a bug in Sencha Touch 2 < Beta 3 that causes the override to not be loaded before the application launches.
It appears the same bug also appears in 4.0.2a. Will investigate further what it takes to fix this in Ext JS 4.0.x.Aaron Conran
@aconran
Sencha Architect Development Team
-
7 Mar 2012 8:31 PM #3
UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
8 Mar 2012 6:35 AM #4
UPDATE:
overriding initComponent() works!
Overriding constructor() doesn't.
Both tested with Ext 4.0.7.
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
8 Mar 2012 8:52 AM #5
We're aware of the problems with Ext JS and are working to address them.
This technique works fine in Touch.Aaron Conran
@aconran
Sencha Architect Development Team
-
8 Mar 2012 9:40 AM #6
Yep, you already said that.
I tried a different approach for "year combo": I wrote a custom component overriding initComponent() + some custom properties so the final result was better: YearComboBox component which I can use anywhere in my application. I also wrote a MonthComboBox (which I need in several views in my application) thanks for the override mechanism.
That problem (constructor override) forced me to think different and the final result was better.
Regards.UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
8 Mar 2012 10:58 AM #7
I may be missing the specificity of your scenario however overloading a store constructor when using 4.0.7 works in my case. Here's an example I'm using right now in order to be able to apply a url resolved through the use of a function, something which is not permitted in the designer:
A difference is that I'm grabbing the proxy after it's been assigned by the super's constructor and then changing the url. Maybe a similar approach (setting the data variable explicitly rather than via config settings) would work for you?Code:Ext.define('Photos.store.override.Images', { requires: 'Photos.store.Images' }, function() { Ext.override(Photos.store.Images, { constructor: function(cfg) { console.log(Ext.String.format('Images: {0}', Ext.photosThumbService)); this.callOverridden(cfg); this.getProxy().url = Ext.photosThumbService; } }); });
-
8 Mar 2012 11:23 AM #8
UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!
-
9 Mar 2012 7:00 AM #9
Same issue
Same issue
I've run into the same issue. I have a store for which I already have data for and wanted to set the data property before the store gets a concrete implementation. I ran down the issue, and it's all about timing.
Basically, the store that I'm overloading is referenced in a view that is creating the store BEFORE, the overload is is applied.
I'm using:
Sencha Designer Version 2.0.0 Build: 309 RC: 2.0-beta
with
Ext 4.0.7
I've been able resolve this by editing the Designer generated code after deployment, but that's been a bit of a pain. I'm going to try overloading the initComponent and see if I get a different result! Thanks!
It would be nice if you could set properties of an object in the designer to a user-defined variable...
Cheers!
BTW...I think this is my first post since Jack owned this...Peter M Corcoran
-
9 Mar 2012 7:57 AM #10UI: Sencha Architect 2.x / ExtJS 4 MVC
Server side: EJB 3.1 / CDI / JPA 2 / JAX-RS / JasperReports
Application Server: Glassfish 3.1.x
Databases: Oracle 10g & 11g / DB2 9 & 10 / Firebird 2.5
If you like my answer please vote!


Reply With Quote
