我有一个combobox,我需要从服务器填充数据。在服务器端,我要显示以下数据。
PersonID
PersonFName
PersonLName
在组合框中,我需要将文本显示为PersonFName + PersonLName(Like James Smith- 这是它将在下拉列表中显示的内容),当用户选择一条记录时,我需要显示相应的PersonID(Like Person with PersonFNameand PersonLNamehas the PersonID of 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'
        }
    ]
});