1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    5
    Vote Rating
    0
    andrewchooah is on a distinguished road

      0  

    Default Answered: Appending HTML to existing HTML of a component ( + general efficiency questions)

    Answered: Appending HTML to existing HTML of a component ( + general efficiency questions)


    I want to append a value to an existing HTML string on a label. I can do this by reading the existing value, and then setting a new value based on the existing plus the new one, as follows:


    Code:
        onDebugPnlActivate: function(container, newActiveItem, oldActiveItem, options) {
            var ioconfig = ADPro.util.Config.getIo();
            var appid = container.down('#appid-label');
            var appsecret = container.down('#appsecret-label');
            var i = appid.getHtml();
            appid.setHtml(i + ioconfig.appId);
        }
    Is there a more efficient way to do this?

    I have a couple more questions regarding efficiency:

    The above example takes place in a Controller Action, where a Panel performs 'activate'. As you can see from the above, I'm acquiring the label element by querying the container.down - again, I wonder if this is an efficient means of both querying, and updating the value of an Element. I know there are many other ways to get a component, and other times during the lifecycle of the software to actually update the value of the component. In this case, I would be setting the value of the labels each time the component is activated - is that going to lead to more executions than necessary? I would like to establish the least-taxing method to make the app as responsive as possible.

    Many thanks for reading.

  2. Yes.Both Ext.get and Ext.getCmp create caches.
    btw,if you need 'appid-label' only once,use 'container.down'(Ext.ComponentQuery.query) for component,'element.down'(Ext.fly) for element.

  3. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Ext.get('appid-label')//if appid-label is element
    Ext.getCmp('appid-label')//if appid-label is component
    I write English by translator.

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    5
    Vote Rating
    0
    andrewchooah is on a distinguished road

      0  

    Default


    Thanks for replying.

    So, is Ext.get / getCmp more efficient than querying the container parameter with .down?

  5. #4
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Yes.Both Ext.get and Ext.getCmp create caches.
    btw,if you need 'appid-label' only once,use 'container.down'(Ext.ComponentQuery.query) for component,'element.down'(Ext.fly) for element.
    I write English by translator.

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

      0  

    Default


    Brilliant advice, thanks very much.

Thread Participants: 1

Tags for this Thread