1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    38
    Answers
    3
    Vote Rating
    0
    rnel is on a distinguished road

      0  

    Default Answered: Retrieve parameters in constructor

    Answered: Retrieve parameters in constructor


    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.

  2. In your constructor do:

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

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

    Regards

  3. #2
    Sencha User
    Join Date
    Jul 2012
    Posts
    3
    Answers
    1
    Vote Rating
    0
    fabergé is on a distinguished road

      0  

    Default


    In your constructor do:

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

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

    Regards

  4. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    38
    Answers
    3
    Vote Rating
    0
    rnel is on a distinguished road

      0  

    Default


    yes, that was true (the first), i've just forgotten. Thanks.

Thread Participants: 1