2013-10-14 22 views
1

我有一個帶有2個DropDownBoxes的程序,其中第一個(用戶值)值的第一個下拉框值被展開。ComboBox值undefined

我的問題是,我試圖從一個下拉框中獲得該值,我得到「不能得到未定義的值」。

這是代碼:

{ 
    xtype: 'combobox', 
    displayField: 'vendor_name', 
    typeAhead: true, 
    mode: 'local', 
    triggerAction: 'all', 
    emptyText: 'Choose vendor...', 
    selectOnFocus: true, 
    fieldLabel: 'Vendor Name', 
    margin: 10, 
    id: 'txtBidVendor', 
    labelWidth: 100, 
    store: Ext.create('Ext.data.Store', { 
     fields: [ 
      {name: 'vendor_name'} 
     ], 
     proxy: { 
      type: 'ajax', 
      timeout: 120000, 
      url: 'GetVendors.jsp', 
      reader: { 
       type: 'json', 
       root: 'data', 
       successProperty: 'success' 
      } 
     }, 
     autoLoad: true 
    }) 
}, 
{ 
    xtype: 'combobox', 
    displayField: 'rate_desc', 
    typeAhead: true, 
    mode: 'local', 
    triggerAction: 'all', 
    emptyText: 'Choose Quality...', 
    selectOnFocus: true, 
    fieldLabel: 'Vendor Quality', 
    margin: 10, 
    id: 'txtBidVendorQuality', 
    labelWidth: 100, 
    store: Ext.create('Ext.data.Store', { 
     fields: [ 
      {name: 'rate_desc'} 
     ], 
     proxy: { 
      type: 'ajax', 
      timeout: 120000, 
      url: 'GetVendorQuality.jsp?' + Ext.urlEncode({'bid_vendor': Ext.getCmp('txtBidVendor').value}), 
      reader: { 
       type: 'json', 
       root: 'data', 
       successProperty: 'success' 
      } 
     }, 
     autoLoad: true 
    }) 
}, 

我在我嘗試讓Ext.getCmp('txtBidVendor').value

+0

是否存在'txtBidVendor'的實例? – Patrick

回答

0

Ofcourse,你不會得到它的線得到錯誤。

您必須在第一個組合的選擇事件偵聽器中設置此第二個URL。

因爲在創建組合前,您正試圖訪問組合中設置的值。 如果您有任何默認值atleast設置加載第一個組合後的第二個組合URL。

1

您需要提及組合的valueField。這將獲取combobox的值。

displayField僅用於提及將顯示的內容。 valueField保留將被訪問的實際值Ext.getCmp('txtBidVendor').value