Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting full model object from a combobox in ExtJs?

Tags:

extjs

extjs4

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?

like image 811
James McMahon Avatar asked Jul 19 '12 21:07

James McMahon


1 Answers

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...
   }
});
like image 149
Russ Ferri Avatar answered Sep 19 '22 21:09

Russ Ferri