Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of selected displayField in ExtJS Combobox

Tags:

extjs

extjs3

How to get the value of selected displayField in ExtJS 3.4 ComboBox? getValue() returns valueField, but I need other.

like image 415
Argnist Avatar asked Jan 14 '13 09:01

Argnist


2 Answers

combo.getValue() -> the valueField
combo.getRawValue() -> the displayField

like image 52
Vinh Doan Avatar answered Nov 15 '22 05:11

Vinh Doan


If this is the case,

displayField : 'countryName',
valueField  : 'countryId',

then following function gives the required displayFiled (Even more than 1 fields are there in store you can get them too)

function getFieldValues(combo, nameIn, nameOut){
     try{
          var r = combo.getStore().find(nameIn,combo.getValue());
          return combo.getStore().getAt(r).get(nameOut);
     }
     catch(err){
          return'error';
     }
}

Way to get the displayfield or any other filed which is in store :

var item = getFieldValues(Ext.getCmp('combo'), 'countryId', 'countryName');
like image 24
vajrakumar Avatar answered Nov 15 '22 05:11

vajrakumar