2011-12-25 67 views
0

我有兩個菜單(myMenu1和myMenu2)和一個窗口(myWin)。我如何動態更改窗口中顯示的菜單。 我需要一個能夠動態更改myWin中項目值的代碼。動態更改ExtJS 3.0中項目參數的值

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 
}); 

回答

0

嘗試擴展您的窗口,然後添加自定義方法 這裏是示例代碼

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); 
    } 
});