1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    6
    Vote Rating
    0
    jessica-qiu is on a distinguished road

      0  

    Question cmp.items.getAt().add cannot work

    cmp.items.getAt().add cannot work


    I'm trying to load 4 buttons in the panel when the page displays, like two in one line, but when I used 'cmp.items.getAt().add', I only can load the last 2 buttons in the panel. I'm so confused about that. Someone else could help me?

    view code (part of):
    items: [{
    layout: 'hbox',
    defaults: {xtype: 'button', ui: 'normal', margin: '40 10', flex: 1, cls: 'homeBtn'},
    items: [],
    },
    {
    layout: 'hbox',
    defaults: {xtype: 'button', ui: 'normal', margin: '40 10', flex: 1, cls: 'homeBtn'},
    items: [],
    }],

    listeners: {

    show:function(cmp){
    console.log('show_homecmp');
    Ext.dispatch({
    controller: App.controllers.mainController,
    action: 'load',
    home_cmp: cmp,
    });
    }
    },

    controller code:


    load: function(options){...
    cmp.items.getAt(0).add({
    text: '<img src="res/icons/mail1-icon.png" class="new"/><div style="font-size:0.8em">Email Return<br/>to Bureau</div>',
    handler: function(){},
    });
    cmp.items.getAt(0).add({
    text: '<img src="res/icons/mail-icon.png" class="new"/><div style="font-size:0.8em">Email Return<br/>(Sample)</div>',
    });

    cmp.items.getAt(1).add({
    text: '<img src="res/icons/Actions-clipboard-icon.png" class="new"/><div style="font-size:0.8em">Publish Reports</div>',
    handler: function(){},
    });

    cmp.items.getAt(1).add({
    text: '<img src="res/icons/import1-icon.png" class="new"/><div style="font-size:0.8em">Import Interface<br/>Files</div>',
    handler: function(){},
    });
    },

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,327
    Vote Rating
    851
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Any errors? ALso, you should use defaultType and specify the xtype you want as the defaultType instead of defining in the defaults Object.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1