1. #1
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    32
    Vote Rating
    1
    silveralecs is on a distinguished road

      0  

    Default Get config vars sent when initializing the component

    Get config vars sent when initializing the component


    I created a custom component, with a custom xtype, and I want to get all the variables sent when the component is initialized. All those variables will be used to instantiate another component. Here's an example:
    Code:
    {
      xtype: 'myCustomField',
      var1: 'test',
      var2: 'test2',
      ....
    }
    In the initComponent method of the component 'myCustomField' I want to retrieve ONLY the variables that we're sent when the component was initialized, no matter what their name is, or how many are they.
    getInitialConfig() doesn't work.

    Thank you,
    Alexandru

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,509
    Vote Rating
    288
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Trying to merge the configurations of 2 components into one, flat config object plays havoc with the 'config overriding the prototype' paradigm at the heart of how initComponent is designed. Form panel has been a nuisance for years because it adopted this kind of approach.

    A common technique for config options like this is to wrap them in their own object. Examples include the boundlist on a combobox or the view for a grid.

    e.g.:

    Code:
    {
        xtype: 'myCustomField',
    
        blahConfig: {
            var1: 'test',
            var2: 'test2'
        }
    }

  3. #3
    Sencha User silveralecs's Avatar
    Join Date
    Apr 2012
    Posts
    32
    Vote Rating
    1
    silveralecs is on a distinguished road

      0  

    Default


    Thank you very much for your reply. This is exactly what I did.
    Though, it would be nice to have them directly into the root of the object.

Thread Participants: 1

Tags for this Thread