2
我的情況是,我有一個編輯窗體,從網格的選定行獲取其數據。 在這種形式存在的類型「下拉框」一些領域,我使用自動完成屬性:使用自動完成組合框與extjs
xtype: 'combobox',
store: 'Paciente',
forceSelection: true,
typeAhead: true,
pageSize: 10,
fieldLabel: 'Paciente',
name: 'paciente_id',
valueField: 'id',
displayField: 'nome',
allowBlank: false,
afterLabelTextTpl: required
這是我的店:
Ext.define('App.store.Paciente', {
extend: 'Ext.data.Store',
model: 'App.model.Paciente',
pageSize: 10,
proxy: {
type: 'rest',
format: 'json',
url: 'pacientes',
reader: {
root: 'pacientes',
totalProperty: 'totalCount'
}
}
});
該組合的作品,使用時。但是當我在網格中選擇一條線時,所有字段都被填充,但不是組合。
gridSelectionChange: function(model, records) {
if (records[0]) {
this.getForm().load(records[0]);
}
},
如何在載入表單時正確填充此組合?
更新1:工作代碼
我不得不爲每個組合框手動完成。我以爲這是一種自動的方式..
if (records[0]) {
this.getForm().loadRecord(records[0]);
//updating current value for combo paciente
this.getStore('Paciente').add({nome: records[0].get('nome'), id: records[0].get('id')});
this.getCombopaciente().select(records[0].get('paciente_id'));
//updating current value for combo XYZ...
}
但是這個自動加載會加載什麼?整個桌子?我真的需要它只用它的id加載記錄。有一些表格有數千個記錄,就像這個Pacients一樣。 – Beetlejuice
您已經爲商店定義了讀者。正如我所看到的,它從「pacientes」網址讀取數據。是不是?如果您想添加manualy,請參閱store add method http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-add – Damask
Hi Prodigy,please see my更新1.謝謝。 – Beetlejuice