1. #1
    Touch Premium Member
    Join Date
    Jun 2008
    Location
    Germany, Dortmund
    Posts
    249
    Vote Rating
    12
    hschaefer123 will become famous soon enough

      0  

    Default Hot to add class config members

    Hot to add class config members


    I would like to add some attributes to my Controller class.

    The new Ext Class Systems automatically generates Getters and Setters,
    but Architect does not allow to add a custom config!

    The custom configs are internally show as _configvalue.

    How can i add custom class members?
    I think the init methods is fired after creation.

    I would like to have some private class members inside my controller that i can access from methods.

    Cheers Holger

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,245
    Vote Rating
    121
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    For types like boolean, array, object and string. Type in "customConfig: true" and then click Add. I've added a custom configuration named customConfig that has a boolean type.

    Code:
    Ext.define('MyApp.controller.MyController', {
        extend: 'Ext.app.Controller',
        config: {
            customConfig: true
        }
    });
    For types like function, add a basic function to the controller.

    If you're looking for something else and I haven't answered your question, please clarify.
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    gbb is on a distinguished road

      0  

    Default


    Where, exactly, does one "Type in "customConfig: true" and then click Add"?

    Thanks.

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    gbb is on a distinguished road

      0  

    Default


    I took a wild guess and typed into the filter box (which I understood to be used to filter existing configs) and to my surprise, the Add button became enabled when it couldn't find what I typed in. Pressing add, added the config.

    Unfortunately when I tried to add a second custom config this way, SA encountered an error:

    TypeError: 'null' is not an object

    So, I guess that wasn't the right thing to try.

    Thanks.

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    gbb is on a distinguished road

      0  

    Default


    I tried adding "redValue: 0" and I just now realized that this - a variable with the value 0 - is not one of the things identified as being able to add this way. So, is there a way to add a numeric config?

  6. #6
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    gbb is on a distinguished road

      0  

    Default


    You're probably wondering how I was able to add a numeric config the first time? I have no idea, but now I have a config that looks like this:

    config: {
    redder: 0,


    control: {
    "sliderfield": {
    change: 'onSliderfieldChange'
    }
    }
    },

    and now I have no way to delete the "redder: 0" config entry. Help?

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    5
    Vote Rating
    0
    gbb is on a distinguished road

      0  

    Default


    So, for all the newbies out there, it appears I ran into a bug of some sort. When I quit SA and restarted it, I was prompted to download an update, which I did. Now when I type "redValue: 0" into the filter field and press Add, it is properly accepted and I can add another one, and then a third one. So, my config looks as follows:

    Code:
        config: {        redValue: 0,
            greenValue: 0,
            blueValue: 0,
    
    
            control: {
                "sliderfield": {
                    change: 'onSliderfieldChange'
                }
            }
        },
    And now a "custom properties" section appears with the above three custom properties (where as, pre-update, something referring to mixins and bubbles existed instead).

    Unfortunately, as each custom property is added, only it appears in the custom properties section - the previously defined custom property disappears, though it is still in the source code. SA needs to be restarted before all three custom properties appear in the custom properties section.

Thread Participants: 2