PDA

View Full Version : [EXTJS 4] ComboBox select event - how to get selected record ?



goldenka
21 Nov 2011, 5:59 AM
Hi,
I have problem with combo box select event. In ExtJs 3.0 there was no problem with accessing record's fields of the combo store, because the select function got 'record' and 'index' parameters.



function(combo, record, index) {
var field = record.data.field;
}

combo.on('select', function, this);


I want to do the same thing in ExtJs 4, but unfortunately select event's parameters are changed: now the function gets 'combo', 'records' and 'elOpts' parameters (no selectedIndex or selectedRecord). Now, the only solution I can see is to try using combo.getValue() and search whole combo store by this value, to find the selected record.

Thank you in advance!!

tobiu
21 Nov 2011, 6:08 AM
take a closer look:


select( Ext.form.field.ComboBox combo, Array records, Object eOpts )
Fires when at least one list item is selected.

Parameters
combo : Ext.form.field.ComboBox
This combo box
records : Array
The selected records
eOpts : Object
The options object passed to Ext.util.Observable.addListener.


with ext js 4, it is possible to allow multi selection in comboBoxes, so an array was needed.
if you are using single select, just get records[0] and it should be the same.

goldenka
21 Nov 2011, 6:11 AM
Thank you !!! :)

kxvenkatesan2
28 Jan 2012, 8:52 AM
try com.getRawValue();