简体   繁体   中英

How to get the value of the selected result on pressing enter in extjs combobox

I have a combobox and i navigate through the search results using the UP/DOWN arrow keys and when i press enter on a particular result,i load a different view and i also need the value(against the valuefield)of the selected result.

I have used specialkey event and if (e.getKey() == e.ENTER) then i do a getValue() and then i load the view. But on getValue(), i get the raw value ie the string that i displayed and not the value against the valuefield(i have displayField:'Name' and valueField:'id').

I also tried firing a select event and in its listener i do a combo.getValue(), still i get the raw value and not the value against the valuefield. I need the id because i may have 2 or more search results with the same name but each one will have a unique id.

Is there a way i can get the value ?

the combobox hooks into 2 events of the picker which should be interesting for you:

me.mon(picker, {
    itemclick: me.onItemClick,
});

me.mon(picker.getSelectionModel(), {
    selectionchange: me.onListSelectionChange,
});

source: http://docs.sencha.com/extjs/4.2.2/source/ComboBox.html#Ext-form-field-ComboBox

you need to hook into this events and then you should have your value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM