PDA

View Full Version : Auto Getters and Setters undefined when accessing class instance for Ext.Base



ssweriduk
8 Nov 2013, 10:30 AM
Hi guys,
I am migrating from Sencha Touch to Ext.js 4.2.1 and I can't seem to get the following to work. I know that in the docs, this is documented as working, but again, can't seem to get it to work... I have the following test case:



Ext.define('MyApp.view.TestClass', {
extend: 'Ext.Base',
testProperty: 'test',
constructor: function(config) {
this.initConfig(config);
}
});


I then execute the following code:



var testClass = Ext.create('MyApp.view.TestClass',
{
testProperty: "HELLO!!!"
}, Ext.emptyFn);
console.log(testClass.getTestProperty());


I get the following error:

TypeError: Object [object Object] has no method 'getTestProperty'

Is there anything I am doing wrong?

burnnat
8 Nov 2013, 12:02 PM
In your class definition, you need to wrap the "testProperty" inside a "config" block. Here's an example:

1f8

mwilliamsShields
15 Nov 2013, 10:34 AM
I'm using Architect 3.0.0.1318 and I can't seem to modify my config to get the properties without doing an override. Is there no way to do this without an override?

ssweriduk
15 Nov 2013, 11:01 AM
Thanks. My problem seems to be stemming from using Architect 3 to generate these custom properties. I have re-asked the question in the Architect 3.x forum. http://www.sencha.com/forum/showthread.php?276119-Auto-Getters-and-Setters-undefined-when-accessing-class-instance-for-Ext.Base&p=1011625#post1011625