ExtJs 继承 和 插件 示例

 1 Ext.ns('Ext.ux');
 2 
 3 function btn(){
 4     alert(this.id);
 5 };
 6 var panel_plugs = {//定义插件
 7     init : function(panel){
 8         panel.width = 600;
 9         panel.height = 300;
10         panel.title = '测试';
11         panel.tools = [{id:"maximize ",handler:btn},{id:"minimize ",handler:btn},{id:"close ",handler:btn}];
12     }
13 };

方法一:

 1 Ext.MyPanel = function(){
 2             //Ext.MyPanel.superclass.initComponent.call(this);
 3             Ext.MyPanel.superclass.constructor.call(this,{
 4                 id : 'div_ext',
 5                 title : 'ceshi',
 6                 width : 600,
 7                 height : 300,
 8                 renderTo : 'div1',
 9                 tbar : [{text:"1"},{text:"2"},{text:"3"}]
10             })
11 };
12 Ext.extend(Ext.MyPanel,Ext.Panel,{
13         plugins : panel_plugs
14 });

方法二:

 1 Ext.MyPanel = Ext.extend(Ext.Panel,{

 2         id : 'div_ext',
 3         title : 'ceshi',
 4         width : 600,
 5         height : 300,
 6         renderTo : 'div1',
 7         tbar : [{text:"1"},{text:"2"},{text:"3"}],
 8 
 9         plugins : panel_plugs
10 // constructor : function(){ 11 // Ext.MyPanel.superclass.constructor.call(this); 12 // }, 13 // initComponent : function(){ 14 // Ext.MyPanel.superclass.initComponent.call(this); 15 // } 16 });

运行代码:

1 Ext.reg('mypanel',Ext.MyPanel);
2 
3 Ext.onReady(function(){
4     new Ext.MyPanel();
5 })

结果图:

posted @ 2015-07-08 15:12  独特之最  阅读(183)  评论(0编辑  收藏  举报