1. #1
    Sencha User
    Join Date
    May 2011
    Posts
    12
    Vote Rating
    2
    wisonye is on a distinguished road

      0  

    Default Answered: In Architect, how to add Ext.create like this? If you know, please tell me, thanks:)

    Answered: In Architect, how to add Ext.create like this? If you know, please tell me, thanks:)


    Ok, my purpose is make some configuration, so let the ComboBox only display parts of string when user make a drop down selection, here is what i want to do:

    Code:
    // .....other config of ComboBox ......
    
    displayTpl: Ext.create('Ext.XTemplate',
        '<tpl for=".">',
        '{[values.name.substr(0,18)]}',
        '</tpl>'
    )
    
    // ..... end of config of ComboBox ......
    So i did this in the Architect, add a new customized field call "displayTpl"( because the standard field list doesn't have it, so i have to ), and then i config that field like above, but when i save, the result is always a "String", look this( focus on "displayField" line ):

    Screen Shot 2013-08-18 at 上午10.17.20.jpg

    And then THAT IS NOT WORKING!!!, no matter how many times i choice by drop down the field type and choose "object", it always be recognized at a string, ....i don't how to do the right thing???

    So i only got one way to do that, write some codes in "afterrender" event to do that, like this:

    Code:
    // .... other config of ComboBox .....
    
    listeners: {
        afterrender: {
              fn: me.onCbDepartingFromAfterRender,
              scope: me
        }
    }
    
    // ..... end config of ComboBox ......

    Code:
    // .... of course we must have this method at somewhere ......
    onCbDepartingFromAfterRender: function(component, eOpts) {
    
          console.log( component.displayTpl );
    
          component.displayTpl = Ext.create('Ext.XTemplate',
                                      '<tpl for=".">',
                                      '{[values.name.substr(0,18)]}',
                                      '</tpl>'
         );
    
    
         console.log( component.displayTpl )
    }
    So, anyone can tell me other ways to do the that except mine???
    And anyone can tell me that: How to make a comment to a function( Architect not allow to modify the code which they generate automatic...)???

    Thanks

  2. Hi,

    At the moment, we do not allow for those types as a custom config. Another way to add a custom config of this type would be to use "processConfig" (http://docs.sencha.com/architect/2/#...s-with-configs). It would look something like this:

    Code:
    processMyComboBox: function(config) {
        // your code //
        config.displayTpl = Ext.create('Ext.XTemplate',
            '<tpl for=".">',
            '{[values.name.substr(0,18)]}',
            '</tpl>'
        );
        /////////////////////
    }

  3. #2
    Sencha - Architect Dev Team dfoelber's Avatar
    Join Date
    Sep 2011
    Location
    Rockville, MD
    Posts
    96
    Answers
    1
    Vote Rating
    12
    dfoelber will become famous soon enough

      2  

    Default


    Hi,

    At the moment, we do not allow for those types as a custom config. Another way to add a custom config of this type would be to use "processConfig" (http://docs.sencha.com/architect/2/#...s-with-configs). It would look something like this:

    Code:
    processMyComboBox: function(config) {
        // your code //
        config.displayTpl = Ext.create('Ext.XTemplate',
            '<tpl for=".">',
            '{[values.name.substr(0,18)]}',
            '</tpl>'
        );
        /////////////////////
    }
    David Foelber
    @davidfoelber
    Sencha Architect Development Team

  4. #3
    Sencha Premium Member
    Join Date
    Jul 2013
    Location
    Atlanta
    Posts
    39
    Answers
    1
    Vote Rating
    3
    ventryj is on a distinguished road

      0  

    Default


    Thank you for this solution! I was having this same problem of rendering a custom display value for a combobox in Architect. Also, thanks for pointing toward process config in the Architect docs. That is a great feature that I wish I would have known about before!

  5. #4
    Sencha Premium Member
    Join Date
    Jun 2010
    Posts
    13
    Vote Rating
    1
    taylon is on a distinguished road

      0  

    Default


    I know I'm late to the game here, but that was exactly what I was looking for this morning so thanks for that. Never really paid attention to what that was.One thing I did notice was that the Architect 3 documentation does not appear to have anything on this.Anyway thanks again!

  6. #5
    Sencha User
    Join Date
    May 2011
    Posts
    12
    Vote Rating
    2
    wisonye is on a distinguished road

      0  

    Default You're welcome for this topic

    You're welcome for this topic


    Architect document miss more useful Practical tips, but you can find them from Sencha con 2013 video alblum( when they talking, they will doing the "faster way" for coding or operation in the Architect, so we got it )

Thread Participants: 3

Tags for this Thread