2013-12-19 4 views
1

나는 콤보 박스와 몇 개의 버튼이있는 팝업 창이있다. 아이디어는 콤보 상자에서 선택을 한 다음 저장소에 선택을 저장하거나 취소하는 것입니다. 이전에이 작업을 수행했지만 문제가 발생하지는 않았지만이 코드를 사용하면 콤보와 상호 작용할 때마다 Uncaught TypeError: Cannot call method 'apply' of undefined이됩니다. ExtJS가 콤보 상자의 저장소를위한 코드를 실행하려고하는 것처럼 보입니다. 콤보가 제대로 초기화되지 않도록 당신이 당신의 Account.Reuse.ComboBoxinitComponent 함수 호출 부모를 잊어 버린 것 같습니다콤보 박스에서 잃는 범위 ExtJS 4.2

Ext.define('SimpleAccount', { 
    extend: 'Ext.data.Model', 
    idProperty: 'AccountID', 
    fields: [ { 
     name: 'AccountID', 
     type: 'int', 
     useNull: true 
    }, 'Name'] 
}); 

var userAccountReuseStore = Ext.create('Ext.data.Store', { 
    model: 'SimpleAccount', 
    storeId: 'userAccountReuseStore', 
    data: [{"AccountID":"1", "Name":"FirstAccount"}, 
     {"AccountID":"2", "Name":"SecondAccount"}, 
     {"AccountID":"3", "Name":"ThirdAccount"}] 
}); 

Ext.define('Account.Reuse.ComboBox', { 
    extend: 'Ext.form.ComboBox', 
    alias: 'widget.accountReuseComboBox', 
    initComponent: function(){ 
     Ext.apply(this, { 
      fieldLabel: 'Account', 
      displayField: 'Name', 
      valueField: 'AccountID', 
      queryMode: 'local' 
     }) 
    } 
}); 

Ext.define('Account.Reuse.Fieldset', { 
    extend: 'Ext.form.FieldSet', 
    alias: 'widget.accountReuseFieldset', 
    initComponent: function(){ 
     Ext.apply(this, { 
      items: [ 
       { 
        xtype: 'label', 
        cls: 'text-important', 
        margin: '0 0 10 0', 
        style: 'display: block', 
        text: 'Only attach an account you have permission to use. After attaching the account you will not be able to use, remove, or edit it until approved by SCSAM' 
       }, 
       { 
        xtype: 'accountReuseComboBox', 
        store: userAccountReuseStore 
       } 
      ] 
     }); 
     this.callParent(); 
    } 
}); 

Ext.define('Account.Reuse.Details', { 
    extend: 'Ext.form.Panel', 
    alias: 'widget.accountReuseDetails', 
    initComponent: function(){ 
     Ext.apply(this, { 
      plain: true, 
      border: 0, 
      bodyPadding: 5, 
      fieldDefaults: { 
       labelWidth: 55, 
       anchor: '100%' 
      }, 
      layout: { 
       type: 'vbox', 
       align: 'stretch', 
       flex: 1 
      }, 
      items: [ 
       { 
        xtype: 'accountReuseFieldset', 
        defaults: { 
         labelWidth: 89, 
         anchor: '100%', 
         layout: { 
          type: 'vbox', 
          defaultMargins: {top: 0, right: 5, bottom: 0, left: 0}, 
          align: 'stretch' 
         } 
        }, 
        title: 'Details', 
        collapsible: false 
       }] 
     }); 
     this.callParent(); 
    } 
}); 

Ext.define('Account.Window.Reuse', { 
    extend: 'Ext.window.Window', 
    alias: 'widget.accountWindowReuse', 
    initComponent: function(){ 
     Ext.apply(this, { 
      title: 'Account Details', 
      width: 400, 
      autoShow: true, 
      modal: true, 
      layout: { 
       type: 'fit', 
       align: 'stretch' // Child items are stretched to full width 
      }, 
      items: [{ 
       xtype: 'accountReuseDetails', 
       id: 'attachAccountReuseForm' 
      }], 
      dockedItems: [{ 
       xtype: 'toolbar', 
       dock: 'bottom', 
       ui: 'footer', 
       layout: { 
        pack: 'center' 
       }, 
       items: [{ 
        minWidth: 80, 
        text: 'Attach', 
        id: 'saveButton', 
        handler: function(){ 
         var rec = this.up('accountWindowReuse').down('accountReuseDetails').getValues(); 
         var store = Ext.getStore('userAccountReuseAttachStore'); 
         store.add(rec); 
         this.up('window').close(); 
        } 
       },{ 
        minWidth: 80, 
        text: 'Cancel', 
        handler: function(){ 
         this.up('window').close(); 
        } 
       }] 
      }] 
     }); 
     this.callParent(); 
    } 
}); 

답변

1

:

나는 Ext.create('Account.Window.Reuse');

정의와 팝업 창을로드합니다.

귀하의 Account.Reuse.ComboBoxinitComponent 기능은 다음과 같아야합니다

initComponent: function(){ 
    Ext.apply(this, { 
     fieldLabel: 'Account', 
     displayField: 'Name', 
     valueField: 'AccountID', 
     queryMode: 'local' 
    }); 
    this.callParent(); 
} 
+0

와우, 내가 그 놓친 믿을 수 없다. 정말 고마워! –