Ext-Ext.form.ComboBox

Ext.create('Ext.form.ComboBox', {
    fieldLabel: 'Choose State',
    store: states,
    queryMode: 'local',
    displayField: 'name',
    valueField: 'abbr',
    renderTo: Ext.getBody()
});
        Ext.onReady(function () {
            // The data store containing the list of states
            var states = Ext.create('Ext.data.Store', {
                fields: ['abbr', 'name'],
                data : [
                    {"abbr":"AL", "name":"Alabama"},
                    {"abbr":"AK", "name":"Alaska"},
                    {"abbr":"AZ", "name":"Arizona"}
                    //...
                ]
            });

            // Create the combo box, attached to the states data store
            Ext.create('Ext.form.ComboBox', {
                fieldLabel: 'Choose State',
                store: states,
                queryMode: 'remote',
                displayField: 'name',
                valueField: 'abbr',
                renderTo: Ext.getBody(),
                listeners:{
                    'select':function (combo,record,opts) {
                        console.log(record[0].raw.name);
                    }
                }
            });

        });

 

posted @ 2022-04-07 17:49  `安安安安安  阅读(19)  评论(0)    收藏  举报