ExtJS 組件添加子組件

來源:互聯網
上載者:User

標籤: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 組件添加子組件

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.