PDA

View Full Version : Retrieve parameters in constructor



rnel
30 Jan 2013, 1:57 AM
Hi,

I'm wondering how can i retrieve parameters i've pass on with Ext.create, how can i retrieve them in the object constructor code ?

Example :

// class definition
Ext.define('MyClass', {

extend : 'Ext.panel.Panel',

width : 500,
height : 300,

constructor : function(??? config or what else ???) {
// now i wanna check a parameter named isExpertMode1 and isExpertMode2
this.isExpertMode = (arguments.isExpertMode1 > 0 ? 2:arguments.isExpertMode2) ; // doesn't work
this.callParent([arguments]) ;
}
}

// now creating an instance with the parameters
var myinstance = Ext.create('MyClass', {
isExpertMode1 : 3,
isExpertMode2 : 5
}) ;

Do you guys see the picture ? How can i proceed to retrieve isExpertMode1 and isExpertMode2 in MyClass constructor ?

Thanks.

fabergé
30 Jan 2013, 4:40 AM
In your constructor do:

constructor: function (config) {
this.isExpertMode = config.isExpertMode1;
}

or check in your argument throught arguments[0] and arguments[1]

Regards

rnel
30 Jan 2013, 10:05 AM
yes, that was true (the first), i've just forgotten. Thanks.