2009-12-24 113 views
1

這裏是我的ExtJS onReady功能爲什麼我的extjs組合框沒有動態填充?

var store = new Ext.data.Store({ 
            proxy: new Ext.data.HttpProxy({ 
            url: '/loginjson.json' 
            }), 

            reader: new Ext.data.JsonReader(
            {root: 'row', fields:['dblist']} 
            ) 
        }); 
      store.load(); 

,在這裏我使用它在我FormPanel中像

renderTo: document.getElementById("loginform"), 
            title: "Login Form", 
            items: [{ 
             xtype: 'combo', 
             fieldLabel: 'genre', 
             name: 'genre', 
             store: store, 
             autoLoad: true, 
             displayField: 'dblist', 
            } 

和JSON網址Django的回報這樣

http://localhost:8000/loginjson.json 

{"row": [{"dblist": "datalist"}]} 

,但我的組合框沒有填充我在extJS的某處丟失了但找不到。

回答

4

如果你期待的組合框的行爲更像是一個HTML選擇字段,然後添加到您的組合框的配置屬性:

triggerAction: 'all' 

這將確保在存儲中的所有項目將點擊字段的觸發按鈕時顯示。

組合框的配置也將需要一個valueField屬性:也

valueField: 'dblist' 

,顯式調用儲存的負載方法是沒有必要的。 ComboBox會在適當的時候爲您處理。

+0

@owlness感謝您的第一次嘗試,您能否向我推薦任何pdf或在線門戶,這可以幫助我理清這些問題。因爲我現在是extjs的虛擬人。 – shahjapan 2009-12-24 14:14:48

+0

ExtJS的最佳資源是ExtJS站點(http://www.extjs.com/)。在API文檔,論壇,示例和wiki(「學習中心」)之間,有大量知識可以獲得。 – owlness 2009-12-25 07:54:59

+0

你爲我省了不少功夫。謝謝貓頭鷹 – Sandeep 2012-08-06 08:29:16

0

我認爲您的JSON閱讀器的fields屬性配置不正確。試試這個:

reader: new Ext.data.JsonReader({ 
      root: 'row' 
     , fields:[{name: "dblist"}] 
     }) 
+0

普通字符串名稱在讀者的字段數組中是可以接受的。他們默認輸入'auto'。 – owlness 2009-12-24 13:25:19

+1

謝謝貓頭鷹! – 2009-12-25 20:45:42