2013-04-30 148 views
1

我想在我的應用程序中添加一個組合框與遠程商店。我有一家商店,調用一個PHP腳本,返回JSON格式的數據,並將其與我的組合框鏈接。 商店是autoLoaded,但我的組合框仍然是空的。 這裏是我的店與遠程ajax商店的自動完成組合框extjs

// Define autocomplete model 
Ext.define('modelloAC', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { name: 'telaio' } 
    ] 
}); 
// store auto complete 
var autoCompleteStore = Ext.create('Ext.data.Store', { 
    model: modelloAC, 
    autoLoad: true, 
    proxy: { 
     type: 'ajax', 
     url: 'script/request.php?operazione=gettelai', 
     reader: { 
      type: 'json', 
      root: 'telai', 
      totalProperty: 'results' 
     } 
    } 
}); 

我的PHP返回一個JSON陣列:

{"results":207,"telai":[{"telaio":"ZAR93200001271042"},{"telaio":"ZLA84000001738127"},{"telaio":"VF3WC9HXC33751301"},{"telaio":"W0L0AHL3555247737"}]} 

我的組合框:

xtype: 'combo', 
    name: 'telaio', 
    //hideTrigger: true, 
    store: autoCompleteStore, 
    typeAhead: true, 
    queryMode: 'remote', 
    fieldLabel: 'Telaio' 

我的存儲加載完美,但我的組合框爲空,哪裏還有問題嗎?

+0

您應該將displayField:'telaio'添加到您的組合框中 – Aminesrine 2013-05-01 08:09:00

回答

1

需要添加displayField和valueField在組合配置:在您的商店

... 
displayField: 'telaio', 
valueField: 'telaio', 
... 

而且現在模型是不確定的。將它寫成字符串:

... 
model: 'modelloAC', 
...