2010-12-06 82 views
0

我使用Ext.extend方法扩展了几个ExtJS组件(Window,DataView等)。我想添加一些额外的属性扩展。我如何将这些添加到我的组件?Custom ExtJs组件的自定义属性

ExWindow = Ext.extend(Ext.Window,{ 
border:false, 
initComponent: function() {  

    // Component Configuration... 
    var config = { 
     height: 500, 
     width: 500, 
     items: [{ 
      xtype: 'simplepanel' 
     }] 
    }; 

    Ext.apply(this, Ext.apply(this.initialConfig, config)); 
    ExWindow.superclass.initComponent.apply(this, arguments);  

}, 
onRender:function() { 
    ExWindow.superclass.onRender.apply(this, arguments); 
} 
}); 
+1

除非你打算在其中包含一些代码,否则不需要包含onRender的覆盖。 – 2010-12-06 08:05:37

回答

0
ExWindow = Ext.extend(Ext.Window,{ 
border:false, 
newPublicProperty: 0, 
newPublicArray: new Array(), 
initComponent: function() {  

    // Component Configuration... 
    var config = { 
     height: 500, 
     width: 500, 
     items: [{ 
      xtype: 'simplepanel' 
     }] 
    }; 

    Ext.apply(this, Ext.apply(this.initialConfig, config)); 
    ExWindow.superclass.initComponent.apply(this, arguments);  

}, 
onRender:function() { 
    ExWindow.superclass.onRender.apply(this, arguments); 
}, 
newPublicMethod:function() { 
} 
}); 

newPublicProperty,newPublicArray,newPublicMethod - 对象的新的附加属性。

+0

不幸的是,我无法访问属性或方法..我得到win.newPublicMethod不是萤火虫的功能! – 2010-12-06 10:30:41