Getting full model object from a combobox in ExtJs?

extjs, extjs4

Solution

In general, you can use the `findRecordByValue` method on the combobox:

combobox.on('change', function(combobox, newValue, oldValue) {

   // Get the old and the new records.
   // NOTE: The underlying store is not guaranteed to 
   //       contain an associated record.
   var oldRecord = combobox.findRecordByValue(oldValue);
   if (oldRecord) {
      // Do something...
   }

   var newRecord = combobox.findRecordByValue(newValue);
   if (newRecord) {
      // Do something...
   }
});

Problem

If I have a store backed combobox selection that fires an event under ExtJS 4, how do I go about getting the full object that is represented by that selection?

Original source