我有一个组合框,它从DB返回10个值;
Ext.define('Iso3Combo', {
extend:'',
xtype:'iso3combo',
requires: [
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
name: iso3
fieldLabel: iso3,
displayField:'iso3', // takes from DB
valueField:'id', // takes from DB
store: {
proxy: {
type: 'ajax',
url: ...getUrl() + '/country/list',
reader: {
type: 'json',
rootProperty: 'data'
}
},
autoLoad: true
},
queryMode: 'local',
autoLoad:true,
bind: '{currRec.iso3}',
listeners: {
fn: function () {
console.log('isocombo listeners...');
},
select: this.getIso3,
change: this.getIso3,
scope: this
}
});
如上所述;combobox
显示的内容是e1d1e,并将id
作为主键。因此,我无法更改valueField。因此,尝试使用此函数来获取所选组合框记录的其他值;
getIso3: function () {
var me = this;
// var rec = me.getSelectedRecords(); //says getSelectedRecords is not a function
var country = me.down('[name=iso3]').getValue(); // returns 'id'
// var isoCode = rec.data.iso3; //Couldn't be success to verify if I get correct value..
如何才能从所选组合框记录加载DB的所有值并选择其中一个?
2条答案
按热度按时间rsaldnfx1#
您需要使用
combobox.getSelection()
或e1d1e。此both方法将返回您选择的记录。或者在select
事件中,您将在第二个parameter
中获得选定的record
,这样您也可以获得iso3
值,如record.get('iso3')
所示。这是一个FIDDLE,我用
form
和combobox
创建了一个演示。这将帮助或指导您解决问题。我正在使用这个**COUNTRY JSON**。
代码段
xwbd5t1u2#