PDA

View Full Version : [SOLVED]combobox setValue problem



9 Jun 2009, 1:38 AM
I am displaying a combobox


combo = new Ext.ux.IconCombo({
id:'savedSearchListCombo',
editable : false,
typeAhead: false,
triggerAction: 'all',
store: comboStore,
valueField: 'id',
hiddenName: "queryId",
displayField: 'name',
triggerAction: 'all',
mode: 'local',
applyTo:'list-saved-searches',
width: 160
});



populated with the following data.


[{id:1, name:'hi'}, {id:2, name:'bye'}]


Now when I say



combo.setValue(1);


Instead of setting selected option to "hi" it showed "1" as selected option. "1" is displayed as displayField in the combo box.
Where am I going wrong?

thanks

Animal
9 Jun 2009, 1:44 AM
Show us your Record and Store definitions.

Do you have a field called 'id'?

9 Jun 2009, 2:08 AM
yes combostore has field called 'id'.



var rowRecord = Ext.data.Record.create([{name: 'name', mapping: 1}]);

var comboStore = new Ext.data.SimpleStore({
fields: ['id', 'name'],
data : []
});


From your hint I changed rowRecord as



var rowRecord = Ext.data.Record.create([{name: 'id', mapping: 0}, {name: 'name', mapping: 1}]);

It is now working fine
Thanks