2011-05-13 16 views
1

我有一個組合B被其他組合B加載(由'select'偵聽器觸發)
一旦B被填充,我看到所有項目,下拉組合中的B,
我力量與鼠標
選擇的第一個項目,我可以選擇其他項目只能通過鍵入

請幫助!!!!對於組合一個
ExtJs組合強制選擇第一個項目(帶示例代碼)


{ 
    xtype: 'combo', 
    displayField: 'value', 
    emptyText: 'Please select A first', 
    fieldLabel: 'Combo A', 
    id: 'comboA', 
    maxHeight: 240, 
    mode: 'local', 
    triggerAction: 'all', 
    typeAhead: true, 
    typeAheadDelay: 100, 
    valueField: 'id', 
    store: new Ext.data.JsonStore({ 
     url: '/cgi-bin/server.cgi', 
     fields: ['id', 'name'], 
     baseParams: { 
      action: 'getAList' 
     }, 
     autoLoad: true, 
     root: 'aList' 
    }), 
    listeners: { 
     'select': { 
      fn: function(){ 
       var comboB = Ext.getCmp('comboB'); 
       comboB.clearValue(); 
       comboB.store.removeAll(); 
       comboB.store.reload({ 
        params: { 
         id: this.getValue() 
        } 
       }) 
      } 
     } 
    } 
} 


代碼

代碼組合B:


{ 
    xtype: 'combo', 
    displayField: 'item', 
    editable: true, 
    emptyText: 'Select a Combo A first', 
    fieldLabel: 'Combo B', 
    id: 'comboB', 
    lazyInit: true, 
    maxHeight: 240, 
    mode: 'local', 
    triggerAction: 'all', 
    typeAhead: true, 
    valueField: 'id', 
    width: 220, 
    store: new Ext.data.JsonStore({ 
     url: '/cgi-bin/server.cgi', 
     root: 'bList', 
     autoLoad: false, 
     fields: ['id,', 'item'], 
     baseParams: { 
      action: 'getBList' 
     }, 
     listeners: { 
      'beforeload': function(){ 
       Ext.getCmp('comboB').disable(); 
      }, 
      'load': function(){ 
       Ext.getCmp('comboB').enable(); 
      } 
     } 
    }) 
} 

回答

0

不知道什麼究竟是錯在這裏,但我懷疑這一塊你comboA不按預期被解僱 -

comboB.store.reload({ 
       params: { 
        id: this.getValue() 
       } 
      }) 

因此comboB仍然被禁用。當你點擊comboB觸發器時,它會加載商店,comboB的商店的加載監聽器正在按預期啓用組合。

嘗試放置一些調試語句或逐句通過上面的代碼段。

相關問題