PDA

View Full Version : Displaying in comboBox name of field, but returning id of field



grigory666
24 Feb 2010, 1:44 AM
I need to display in comboBox one value. And I want to getVaue function returns another value. Here is my try:


var boolStore = new Ext.data.ArrayStore
({
idIndex : 'bool',
fields : ['bool','value'] ,
data : [['Yes',true],['No',false]]
});


new Ext.form.ComboBox
({
width : 48,
store : boolStore,
value : ‘Yes',
valueField : 'value',
displayField : 'bool',
typeAhead : true,
mode : 'local',
forceSelection : true,
triggerAction : 'all',
selectOnFocus : true
});

I want, getValue function returns true or false, but it treturns ‘Yes’ or ‘No’
Where am I wrong? How to do it correct?

grigory666
25 Feb 2010, 12:28 AM
I think, it is a simple question
please help me, somebody

tobiu
25 Feb 2010, 12:36 AM
good morning grigory666,

take a close look at:



fields : ['bool','value'] ,
data : [['Yes',true],['No',false]]


which field contains 'Yes' or 'No'?


kind regards,
tobiu

grigory666
25 Feb 2010, 12:45 AM
fields in "data" contain 'Yes' or 'No'
It is like in ComboBox example
I don't understand, where is the mistake

Vepe
25 Feb 2010, 3:50 AM
Here it worked like this





var boolStore = new Ext.data.ArrayStore
({
fields : ['bool','value'] ,
data : [['Yes',true],['No',false]]
});


var combo = new Ext.form.ComboBox
({
store : boolStore,
valueField : 'value',
displayField : 'bool',
typeAhead : true,
mode : 'local',
forceSelection : true,
triggerAction : 'all',
selectOnFocus : true
});



To get the value I did combo.getValue();

See if it works =)

tobiu
25 Feb 2010, 4:19 AM
still completely blind...

the MATCHING!!!

your valueField is bool.
The field bool has the values Yes / No

your displayField is value
The field value has the values true / false

tobiu
25 Feb 2010, 4:22 AM
and you mix up two configs:


value : ‘Yes',

is not the best choice when using valueField.

try:


hiddenValue:true

or both.


kind regards,
tobiu

Vepe
25 Feb 2010, 5:36 AM
but he was showing the "yes" and "no"




....
fields : ['bool','value'] ,
data : [['Yes',true],['No',false]]
....

valueField : 'value', ===> true
displayField : 'bool', ===> Yes


Or I'm missing something?