EXTJS MVC模式下controller如何绑定✀添加✀和✀删除✀这两个button

2025-05-19 07:47:51
推荐回答(2个)
回答1:

在ExtMVC中通过controller的查找器来查询你的控件,

首先你可以设置你的button的itemId,或者为其加入action属性,

代码如下:

...//此处省略代码
 this.button= [{ 
        text: '添加',
        scope: this,
        itemId:'add'  
},{
        text: '删除',     
        scope: this,
        action:'delete' 
}];

在controller中邦定事件

代码如下:

Ext.define('YourControllerSrc',{//你controller的地址
    extend:'Ext.app.Controller',
    init:function(){
        this.control({
            "companyqualification #add":{//添加按钮点击事件
                click:function(obj){}  
            } 
  
            "companyqualification [action=delete]":{//删除按钮点击事件

                click:function(obj){}  

            } 
        });  
    }   
})

 个人建议使用第二种 避免id重复

回答2:

companyqualification toolbar button[text="添加"]