PDA

View Full Version : combobox default item or value selected



spor
22 Mar 2010, 6:58 AM
Is there a config for combobox to have a default item selected in a combobox, e.g when using Ext.data.ArrayStore for storing the items?

Condor
22 Mar 2010, 7:04 AM
'value' and 'hiddenValue'?

spor
22 Mar 2010, 7:15 AM
How do you use that 'value'?

var templateStore = new Ext.data.ArrayStore({
data : [['template color 1'], ['template color 2]],
fields : ['template']
});

var templateCombo = {
xtype : 'combo',
fieldLabel : 'Choose template',
store : templateStore,
displayField : 'template',
typeAhead : true,
mode : 'local',
value : templateStore[0] // Something like this didn't work...
};

Condor
22 Mar 2010, 7:28 AM
It should be:

value: templateStore.getAt(0).get('template')

spor
22 Mar 2010, 7:38 AM
Thanks, Condor, that worked. However, whenever there is a value selected, either manually or pre-selected like in this case, other values apart fromt the selected one, aren't visible anymore on the dropdown. Is there a way to prevent this?

Condor
22 Mar 2010, 7:47 AM
Also configure you combobox with triggerAction:'all'.

spor
23 Mar 2010, 12:32 AM
Condor, thanks again for your help!