2012-09-21 29 views
3

我有一個ExtJs組合框。它的商店使用JSON加載(使用我的商店)。我想將所有值加載到商店,然後使用在組合文本字段中輸入的文本對它們進行過濾。在ExtJs中篩選combox

我不希望我的組合在我輸入內容時重新加載它的商店。我怎樣才能做到這一點? 和其他的東西,然後我嘗試從組合框首次從服務器重新加載數據時選擇元素。 PS:我的商店中的偵聽器,用於從服務器中選擇第一個數據元素。 謝謝。

這裏是我的店鋪等級:

Ext.define('KP.store.account.street', { 
    extend: 'Ext.data.Store', 
    model: 'KP.model.account.combo', 
    autoLoad: true, 

    proxy: { 
     type: 'ajax', 

     api: { 

      read: '/account/combostreetdata' 
     }, 
     reader: { 
      type: 'json', 
      root: 'combolist', 
      successProperty: 'success', 
      totalProperty: 'total' 
     } 
    }, 

    listeners: { 
     'load': function (street_list) { 
      var street_combo = Ext.getCmp('street'); 
      street_combo.select(street_list.getAt(0)); 
     } 
    } 
}); 

我的觀點:

{ 
    id: 'street', 
    xtype: 'combobox', 
    width: 700, 
    name: 'street', 
    editable: true, 
    mode: 'local', 
    typeAhead: true, 
    emptyText: '?????', 
    fieldLabel: '???', 
    labelWidth: 120, 
    size: 72, 
    x: 20, 
    y: 180, 

    displayField: 'string_value', 
    valueField: 'long_key', 
    store: street_list 
}, 

回答

0

你有一個組合框配置錯誤。

不是mode: 'local',而是queryMode: 'local',

我在連擊使用這樣一個領域:

queryMode: 'local', 
forceSelection: true, 

工作事先鍵入的內容細,預輸入期間沒有數據負載。

+0

謝謝,我的錯誤。但是你知道爲什麼然後我試着從combobox中選擇元素,第一次是從服務器重新加載數據? –

+0

嗯。嘗試將'proxy'配置選項放入模型中,並將其從商店中刪除。 –