標籤:style io ar os 使用 sp on cti bs
【1 添加子組件】
Ext.onReady(function(){//ex002 : 在組件中添加子組件 ,並進行一系列針對於組件的操作//在組件中添加子組件:/*var win = new Ext.window.Window({title:"添加子組件執行個體" , width:‘40%‘ ,height:400 , renderTo:Ext.getBody() ,draggable:false , //不允許拖拽resizable:false , //不允許改變視窗大小closable:false, //不顯示關閉按鈕collapsible:true ,//顯示摺疊按鈕bodyStyle: ‘background:#ffc; padding:10px;‘ , // 設定樣式html:‘我是window的內容!!‘ ,//Ext items(array) 配置子組件的配置項items:[{ //組件中 添加子組件//Ext的組件 給我們提供了一個簡單的寫法 xtype屬性去建立組件xtype:‘panel‘,width:‘50%‘,height:100 ,html:‘我是面板‘},new Ext.button.Button({text:‘我是按鈕‘ , handler:function(){alert(‘執行!!‘);}})//{//xtype:‘button‘ , //用一個xtype相當於new一個對象。//text:‘我是按鈕‘,//handler:function(btn){//alert(‘我被點擊了‘);//alert(btn.text);//}//}]});win.show();*/
【2 添加子組件 使用 tbar , bbar , 等】
//第二種方法添加子組件, tbar config 屬性var win = new Ext.Window({id:‘mywin‘ ,title:‘操作組件的形式‘ ,width:500 , height:300 , renderTo:Ext.getBody() , //tbar表示在當前組件的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//console.info(btn.ownerCt);//上一級 是 tbaralert(btn.ownerCt.ownerCt.title);}}]});win.show();
ExtJS 組件添加子組件