javascript - Accesing Ext Component Config -
i have simple extension in ext js ext.form.panel:
ext.define('path.to.someclass', { extend : 'ext.form.panel', xtype : 'some-class' config : { hasdog : true }, constructor : function (config) { if (this.config.hasdog) { // dog related } else { // not dog related } } }); i have "container" custom componet:
ext.define('path.to.otherclass', { extend : 'ext.window.window', // .... items : [{ xtype : 'some-class', hasdog : false }] }); however, reason unknown me, if...else evaluation in someclass picking default configuration hasdog. not correctly configuring some-class in otherclass's items config?
to add bit more context, otherclass called via using code:
var window = ext.create('path.to.otherclass'); window.show(); from can see, above pretty standard stuff - @ least in thought.
the reason why default configuration because you're accessing this.config, declaration of configuration, instead of actual configuration constructor argument. either use config or - once you've called parent class constructor - this.
constructor : function (config) { // before parent class constructor or this.initconfig called: console.log(config.hasdog); // call parent class constructor this.callparent(arguments); // after parent class constructor or this.initconfig called: console.log(this.hasdog); } also have @ documentation:
note: need make sure ext.base.initconfig called constructor if defining own class or singleton, unless extending component. otherwise generated getter , setter methods not initialized.
in case, since extending component, calling parent constructor should suffice (as shown in example above).
Comments
Post a Comment