繁体   English   中英

在ExtJS 3.0中动态更改items参数的值

[英]Dynamically change the value of items parameter in ExtJS 3.0

我有两个菜单(myMenu1和myMenu2)和一个窗口(myWin)。 如何动态更改窗口中显示的菜单。 我需要一个可以动态更改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
});

只需添加菜单: myWin.add(myMenu1, myMenu2); API在这里: http : //docs.sencha.com/ext-js/3-4/#!/api/Ext.Window-method-add

尝试扩展Windows,然后添加自定义方法,这是示例代码

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM