0
votes

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 ?

1
can you adjust this fiddle so that I see your problem, cause this example is workingJan S
I use MVC & in my controller I have a listener for specialkey event and select event. I fire event to load a different view when Enter is hit and I want to set the value (against value field) of the selected result from the combobox in a variable before the view is loaded. But the problem is View is loaded before and then the value is set. specialkey :function(field,e){ if(e.getKey == e.ENTER){ // var value = field.getValue(); //this gives me the raw value and not the actual value fireEvent(‘loadView’); } }, select :function(combo){ var value =combo.getValue();//get actual value here }user3259903
jsfiddle.net/dT3ZL. Similar to this fiddle,but i need the value before the the view loads.As of now the view loads and then i get the valueuser3259903
Just wanted to know ,is select the only event which can give me the actual value (specified against the valuefield) or are there more events?user3259903

1 Answers

1
votes

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