2011-10-08 70 views
1

我有一個編輯器網格面板,有2個字段。基於第一個字段,第二個字段應該更改爲具有其他選項的組合框。爲此,需要運行第一個字段的值來激發第二個字段的查詢。 該代碼工作正常並重新獲取數據。但即使第二個字段的寬度爲350,出現的組合框也非常小,無法讀取。即使下拉沒有看到。我也嘗試了ListWidth屬性..但沒有改變輸出。Extjs combobox不顯示數據

是因爲,最初組合框是空的,我使用beforequery屬性來更改帶有id字段的url,所以組合框沒有獲取數據?但我在螢火蟲上看不到任何錯誤。

我有以下代碼:

createGrid= function(e){ 
    var store= new Ext.data.Store({ 
     autoLoad: true, 
     proxy: new Ext.data.HttpProxy({ url: ..... }) //url to get the data 
     reader: new Ext.data.JsonReader({ 
      root: //the root, 
      id: //id, 
      sortInfo: {field: 'id', direction: 'ascending' }, 
      fields: ['id','fields'] 
     }) 
    }); 

    var store2= new Ext.data.store ({ 
     autoLoad: true, 
     id: 'store2', 
     proxy: new Ext.data.HttpProxy({ url: ' '}) //url 
     reader: new Ect.data.JsonReader({ 
      root: 'enums','id', fields: ['enum_id','value'] 
     }) 
    }); 


    var cm=new ext.grid.columnModel([ 
     {id:'id',name:'id',dataIndex: 'id', width: 300}, 
     {id:'fields', header: 'fields',width: 350, editor: new Ext.form.ComboBox({ 
      name: 'combo', 
      store: store2, 
      width: 350, 
      valueField: 'enum_id', 
      displayField: 'value', 
      listeners: { 
       beforequery: function(query){ 
        var g_n=Ext.getCmp('grid1'); 
        var s_t=g_n.getSelectionModel().getSelections(); 
        var record=s_t[0]; 
        var assign_data=record.get('id'); 
        var actionStore=Ext.StoreMgr.get('store2'); 
        var action_combobox=Ext.getCmp('combo1'); 
        actionStore.proxy.conn.url=' ',//new url which requires the 'id' field 
        actionStore.load(); 
        return query; 
       } 
      } 
     })}, 
    ]); 


    return new Ext.grid.EditorGridPanel({ 
     id: 'grid1', 
     store: store, 
     cm:cm, 
     sm: new Ext.grid.RowSelectionModel ({ singleSelect: true}); 
     autoExpandableColumn: 'fields', 
     listeners: { 
      //the other grid listeners 
     } 
    }) 
} 

請幫我解決這個問題。 在此先感謝。

+0

什麼是您正在使用ExtJS的的版本替換Ext.data.store?另外,這裏的'combo1'代表哪個字段用於你的聽衆'beforequery'中?作爲一個隨機檢查,我希望您的商店字段和來自服務器的JSON密鑰存在匹配。 – netemp

+0

我正在使用extjs-3.3.1。而且,一旦用戶點擊「字段」單元格,網格面板中的字段「字段」就會被替換爲組合框。在螢火蟲中,我可以看到值得到檢索。在螢火蟲中沒有顯示錯誤。唯一的事情是,組合框的寬度非常小,下拉也沒有顯示出來。 – user977933

+0

組合框的名稱是'combo1'..對於代碼部分的拼寫錯誤。 – user977933

回答

0
var store2 = new Ext.data.store(

也許你需要Ext.data.StoreExt.data.JsonStore