我有一个combobox
,我需要从服务器填充数据。在服务器端,我有以下数据要显示。从远程服务器填充Combobox
PersonID
PersonFName
PersonLName
在ComboBox,我需要显示的文字为PersonFName + PersonLName
(像James Smith
- 这是它会在下拉显示向下),并且当用户选择一个记录,我需要显示相应的PersonID
(如PersonFName
和PersonLName
的人拥有该用户的PersonID 1
)。
我无法想出解决办法,这是我的代码
查看:
{
xtype: 'combobox',
id: 'personcombo',
readOnly: false,
selectOnFocus: true,
forceSelection: true,
store: 'Person'
}
商店:
Ext.define('MyApp.store.PersonStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.Person'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'MyApp.model.Person',
proxy: {
type: 'ajax',
api: {
read: 'person.php',
create: 'person.php'
},
reader: {
type: 'array'
}
}
}, cfg)]);
}
});
型号:
Ext.define('MyApp.model.Person', {
extend: 'Ext.data.Model',
fields: [
{
name: 'PersonID'
},
{
name: 'PersonFName'
},
{
name: 'PersonLName'
}
]
});
你现在看到什么?主要问题是“如何显示组合字段”? – sha 2012-08-02 12:37:15
是的,你是对的。我需要知道如何显示组合字段。 – Illep 2012-08-03 17:06:32
看看@Geronimo如何创建动态字段的答案。 – sha 2012-08-03 17:08:54