2012-04-29 38 views
0

我對組合框有點問題。 我有一個組合框存儲,在某些事件後使用ajax重新加載。之後,我使用myCombo.setValue()來設置默認的組合框選擇字段。它運作良好。問題是當我點擊組合並顯示下拉列表時。該列表自動隱藏。但只有在第一次,然後每件事情都很好,直到我重新填寫表格。 我可以證明我的代碼的一部分:存儲加載後extjs 4.0.7中Combobox中的小bug

店:


var ParentsStore = Ext.create('Ext.data.Store', { 
    autoLoad: false, 
    fields: ['id', 'name'], 
    proxy: { 
     type: 'ajax', 
     url: 'index.php?aid=parents_combostore', 
     reader: { 
      type: 'xml', 
      record: 'item', 
      idProperty: 'ASIN', 
      totalRecords: '@total' 
     } 
    } 
}); 

它重裝店:


Ext.getCmp('userParent_combo_id').clearValue(); 

     ParentsStore.getProxy().extraParams = 
     { 
       typ :typ['usrtyp_id'] 
     }; 
      Ext.getCmp('userParent_combo_id').store.load(); 
      Ext.getCmp('userParent_combo_id').lastQuery = null; 

是否有人瞭解我,可以嘗試幫助我嗎?

最好的問候!

回答

0

load()方法是異步的。這意味着在您致電load()後,您不能假設商店正確加載。您需要配置商店加載事件的處理程序,並繼續您的邏輯 - setValue()等。

+0

謝謝你的回答,但我知道。我試着用處理程序,但它不能正常工作..數據加載,我知道它,但是當我下拉列表時,我看到它0.2秒,它隱藏起來。它看起來正確。當我再次下拉時,它運作良好。 –

+0

很多人都在使用這種產品的基本功能,這很難想象。我沒有看到我的項目中任何地方的連接和遠程存儲都有問題。請爲您的組合框定義和工作流發佈更多代碼。 – sha

+0

我沒有寫錯誤是在庫中,但它在我的代碼中! :) 明天我放更多的代碼..我必須等待8個小時纔再次發佈.. :)謝謝你的幫助! –

0

我不認爲一個錯誤是在圖書館,但只在我的代碼!

這是其中的一部分,當我稱之爲負載存儲


xtype: 'radiogroup', 
        columns: 1, 
        fieldLabel: 'typ', 
        id: 'typ_radio_id', 

        items: [ 
         usrtyp_item 
        ], 
        listeners: { 
          change: { 
           fn: function(field,new_value,old_value,options) 
           { 
             typ=Ext.getCmp('typ_radio_id').getValue(); 

             if(second_change) 
             { 
              Ext.getCmp('userParent_combo_id').clearValue(); 


              ParentsStore.getProxy().extraParams = { 
               typ :typ['usrtyp_id'] 
              }; 
              Ext.getCmp('userParent_combo_id').store.load(); 
              Ext.getCmp('userParent_combo_id').lastQuery = null; 

              second_change=0; 
             } 
             else second_change=1; 

           } 
          } 
        } 

,這是聽衆樹面板上,在這裏我用的setValue


listeners: { 
      'itemclick': function(this_el,record,item,index,e,eOpts) 
      { 
        var user_info = getUserById(record.get('id'));  


         parent_id=user_info['parent_id']; 
         second_change=0; 

         Ext.getCmp('userParent_combo_id').setValue(parent_id); 
      } 
} 

「itemClick在」一個「變」事件後, radiogroup自動啓動。這是我的代碼的一部分,但是這個重要的部分。