[ACCEPTED]-how to get the value on extjs combo box?-extjs4

Accepted answer
Score: 12

Simply use the select event

var simpleCombo = Ext.create('Ext.form.field.ComboBox', {
            store: store,
            displayField: 'data1',
            valueField: 'data1' ,
            width: 250,
            labelWidth: 120,
            fieldLabel: 'select a value',
            renderTo: 'simpleCombo',
            queryMode: 'local',
            typeAhead: true,
            listeners: { 
               select: function(combo, records) {
                   // note that records are a array of records to be prepared for multiselection
                   // therefore use records[0] to access the selected record
               }
        });

API Link

Additional content from the comments:

Take a look at 12 the multiSelect property of the combobox. You get all 11 values separated by a defined delimiter 10 and the select event will give you a records 9 array with more that one record. Note the 8 that getValue() only give you the defined 7 displayField which is a string and not the 6 record itself. So using iComboValue[0] gives 5 you the first character. The selected records 4 should always be accessed using the selected 3 event. But you may store them in a array 2 for later use and overwrite it with any 1 new select.

Score: 10

You can also use:

var iComboValue = simpleCombo.getValue();

0

Score: 0

may be you should try this

 // to get the combobox selected item outside the combo listener
        simpleCombo.on('change', function (combo, record, index) {

            alert(record);  // to get the selected item

            console.log(record);  // to get the selected item

        });

0

More Related questions