11

How can I add dynamically an new item in Ext.panel ? This is the code I'm using;

app.views.ViewItem = Ext.extend(Ext.Panel, {
    id: '0',
    dockedItems: [{
        xtype: 'toolbar',
        title: 'Melvin test',
        items: [
            {
                text: 'Terug',
                ui: 'back',
                listeners: {
                    'tap': function () {
                        Ext.dispatch({
                            controller: app.controllers.appController,
                            action: 'backToRssList',
                            animation: {type:'slide', direction:'right'}
                        });
                    }
                }
            },
            {xtype:'spacer'},
            {
                id: 'share',
                text: 'Delen',
                ui: 'action',
                listeners: {
                    'tap': function () {
                        Ext.dispatch({
                            controller: app.controllers.appController,
                            action: 'share',
                        });
                    }
                }
            }
        ]
    }],
    items: [],
    initComponent: function() { 
        app.views.ViewItem.superclass.initComponent.apply(this, arguments); 
    },
    getView: function(data) {
        //this.items.add({html: 'test'});
    },
});

In the function getView I am trying to add an new item with this line;

this.items.add({html: 'test'});

The error that is showing up ( in Rockmelt, Chrome ) is;

Uncaught TypeError: Object #<Object> has no method 'getItemId'

Obviously this isn't working, what am I doing wrong?

Marcus
  • 12,296
  • 5
  • 48
  • 66
Melvin
  • 3,421
  • 2
  • 37
  • 41

1 Answers1

16

Did you try using the add() function for the panel itself? E.g:

this.add({html: 'test'});
Nicodemuz
  • 3,539
  • 2
  • 26
  • 32
  • @user706933 again thanks for the reply on this but please mark the answer as correct to close the question. – sra Apr 28 '11 at 21:21