PDA

View Full Version : Combobox and hidden fields



Andr
19 Sep 2011, 1:30 AM
Hi all. I have a problem with showing hidden field value.

My code:


var MyComboBox = Ext.extend(Ext.form.ComboBox, {
initComponent : function() {
Ext.apply(this, {
store : Store ,

displayField : 'name',
valueField : 'id',

typeAhead : true,
mode : 'local',
forceSelection : true,
triggerAction : 'all',
selectOnFocus : true
});
MyComboBox.superclass.initComponent.apply(this, arguments);
}
});


// Select event.
var combo1 = new MyComboBox({
name : 'combo1',
applyTo : 'combo1',
hiddenName : 'hcombo1', // hidde field
hiddenValue : 'id',

listeners : {
'select' : function() {
combo2.setValue(combo1.getValue());
}
}
});

var combo2 = new MyComboBox({
name : 'combo2',
applyTo : 'combo2',
listeners : {
'select' : function() {
alert(combo1.getRawValue()); // print hidden value (id of record)
}
}
});


I need value of hidden field with name - hcombo1. But code alert(combo1.getRawValue()) - print not ID, they print NAME. What I do wrong ?
ExtJS 3.3.1

Andr
27 Sep 2011, 1:24 AM
// Select event.
var combo1 = new MyComboBox({
id : 'combo1', //-- ADD ID
name : 'combo1',
applyTo : 'combo1',
hiddenName : 'hcombo1',
hiddenValue : 'id',

listeners : {
'select' : function() {
combo2.setValue(combo1.getValue());
}
}
});

var combo2 = new MyComboBox({
name : 'combo2',
applyTo : 'combo2',
listeners : {
'select' : function() {
alert(Ext.getCmp("combo1").getValue()); // -- TREATMENT
}
}
});