How to get the value of selected displayField in ExtJS 3.4 ComboBox? getValue() returns valueField, but I need other.
4 Answers
6
votes
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');
0
votes
Maybe u just user store.filter(), right? If that, try clear filter and load again like below:
onProvinceSelected: function (com,record,index)
{
var provinceCode = com.getValue();
var postGrid = this.lookupReference('postgrid');
if (provinceCode != 0) {
postGrid.store.filter('ProvinceCode', provinceCode);
} else {
postGrid.store.filters.clear();
postGrid.getStore().load();
}
}
valueField
is in your case can you clarify what you need then? – srasetValue()
. So you will need to extend the combo class to add such a behavior. Dunno if that is an option for you, but the is no other way – sra