Goran
Goran

Reputation: 17

Dynamically change the value of items parameter in ExtJS 3.0

I have two menus (myMenu1 and myMenu2) and one window (myWin). How can I dynamically change the menu that is displayed in the window. I need a code that will dynamically change the value of items in myWin.

var myMenu1 = new Ext.Toolbar({
        width: 700,
        items: [{
            xtype: 'tbbutton',
            text: 'Add',
            icon: 'add_icon.gif',
            handler: displayFormWindow
             }]
    });

var myMenu2 = new Ext.Toolbar({
        width: 700,
        items: [{
             xtype: 'tbbutton',
             text: 'Delete',
             icon: 'del_icon.gif',
             handler: displayFormWindow
               }]
    });

var myWin = new Ext.Window({
      id: 'myWin',
      height: 450,
      width: 710,
   // items: myMenu1
   // items: myMenu2
});

Upvotes: 0

Views: 358

Answers (2)

kunkun kurniawan
kunkun kurniawan

Reputation: 86

try with extend your windows and then add custom method here is sample code

myWindow = new Ext.extend(Ext.Window,{
    constructor:function(config){
       // add your code here
       myWindow.superclass.constructor.call(this);
    },
    addMethod: function(){
       // add your code here
       myWindow.superclass.show.call(this);
    },
    deleteMethod: function(){
       // add our code here
       myWindow.superclass.show.call(this);
    }
});

Upvotes: 0

Chao
Chao

Reputation: 1058

Simply add the menus: myWin.add(myMenu1, myMenu2); API is here: http://docs.sencha.com/ext-js/3-4/#!/api/Ext.Window-method-add

Upvotes: 1

Related Questions