2015-01-10 4 views
0
Ext.define('RevenuePanel', {  extend: 'Ext.panel.Panel', 
items: [ 
..........   
Ext.create('Ext.button.Button', {text: 'Button'})  ] 
}); 

이 경우 items 속성이 클래스의 프로토 타입에 복사됩니다.
응용 프로그램 내에서 여러 컨테이너에서 항목에 대한 사용자 지정 동작을 패널에 허용하도록 허용하는 좋은 프로그래밍 방법은 무엇입니까?공유 구성 요소 사용자 정의

우리는 Ext3.4x

답변

2

나는 그냥 미리 정의를 무시하지 않고, 더 많은 항목을 추가 할 가정에 있습니다.

Ext.define('RevenuePanel', {  
    extend: 'Ext.panel.Panel', 
    initComponent: function(){ 
     var me = this, 
      newItems = me.items, 
      defaultItems, items; 
     // apply your default items 
     defaultItems = [{xtype:'button', text:'Button'}]; 
     // check if there are new items defined for this instance 
     if(typeof newItems != 'undefined') { 
      items = defaultItems.concat((newItems instanceof Array) ? newItems : [newItems]); 
     } else { 
      items = defaultItems; 
     } 
     // override the items 
     me.items = items; 

     me.callParent(arguments); 
    } 

}); 
관련 문제