extjs操作组件的形式

来源:互联网 发布:c语言编写有窗口的程序 编辑:程序博客网 时间:2024/05/21 22:42
var win=new Ext.window.Window({                                                           
id:'mywin',                                                                           
    title:"操作组件的形式",                                                                      
    width:"50%",                                                                          
    height:300,                                                                           
    renderTo:Ext.getBody(),                                                               
    //表示当前组件top位置添加一个工具条                                                                  
    tbar:[{  //bbar(bottom)底部 lbar(leftbar)左部 rbar(rightbar)有部 fbar(footbar)底部按钮          
       text:'按钮1',                                                                        
       handler:function(btn){                                                             
       //组件都会有up、down这两个方法(表示向上向下查找)需要的参数是组件的xtype或者选择器                                   
        alert(btn.up('window').title);                                                    
                                                                                          
       }                                                                                  
                                                                                     
    },{                                                                                   
      text:'按钮2',                                                                         
      handler:function(btn){                                                              
      //最常用的方法                                                                            
      alert(Ext.getCmp('mywin').title);                                                 
      }                                                                                   
    },{                                                                                   
      text:'按钮3',                                                                         
      handler:function(btn){                                                              
      //以上一个组件的方式查找ownerCt                                                                
      alert(btn.ownerCt.ownerCt.title);A                                                
      }                                                                                   
    }]                                                                                    
                                                                                     
});                                                                                       
win.show();                                                                               
                                                                                          
1 0