几天前我开始使用 extJS,在我的标题应用程序中,我有一个组合框和一个文本字段。
组合框有 3 个值,在组合框中选择其中一个值后,该值不会出现在 textField 中
这是我的商店:
Ext.define('Terms.store.groupStore', {
extend: 'Ext.data.Store',
alias: 'store.groupstore',
fields : [
{
name : 'groupName',
type: 'string'
},
{
name : 'accountId',
type: 'int'
}
],
data : [
{
groupName : 'GROUP1',
accountId : '1'
}, {
groupName : 'GROUP2',
accountId : '2'
}, {
groupName : 'GROUP3',
accountId : '3'
}
],
proxy : {
type : 'memory',
reader : {
type : 'json'
}
},
autoLoad : true
});
Combobox 位于标题中,textField 位于其旁边:
Ext.define('Terms.view.main.HeaderBar', {
extend: 'Ext.Toolbar',
xtype: 'headerBar',
items: [
{
xtype: 'panel',
layout: 'hbox',
flex: 15,
layoutConfig: {
align: 'stretch'
},
items: [
{
xtype: 'panel',
flex: 4,
layout: 'hbox',
renderTo: Ext.getBody(),
defaults: {
labelAlign: "left"
},
items: [
{
xtype: 'combobox',
name: 'accountId',
displayField : 'groupName',
valueField : 'accountId',
flex: 2,
id: 'accountId',
fieldLabel: 'Group',
labelWidth: 45,
store : {
type : 'groupstore'
},
listeners: {
change: function (combo, newValue, oldValue) {
var value_index = groupstore.find('accountId', newValue);
var record = groupstore.getAt(value_index);
Ext.getCmp('fieldGroup').setValue(record.get("groupName"));
}
}
},
{
xtype: 'textfield',
flex: 2,
name: 'fieldGroup',
id: 'fieldGroup',
allowBlank : true,
hideTrigger : true,
valueField: 'fieldGroup',
store : 'groupstore',
style: 'margin-left: 10px;'
}
]
}
]
}]
});
组合框从商店中加载数据,我可以单击它并选择它,但该值/数据不会出现在它旁边的文本字段中。对此有何建议?