PDA

View Full Version : by default select first item for combobox having array as store



santoshsatav
1 Dec 2010, 10:29 PM
is there any straight forward way it without using events to set first item in array store to be set as selected when combo rendered first time.:-/

Screamy
2 Dec 2010, 10:39 AM
Since you're using an ArrayStore, yes. Set the combo's value attribute to the desired store ID:



var combo = new Ext.form.ComboBox({
xtype: 'combo',
displayField: 'label',
mode: 'local',
store: new Ext.data.ArrayStore({
fields: ['val', 'label'],
data: [['tst', 'Select a Test'],['clr', 'Select a Color'],['phn', 'Select a Phone Number']]
}),
triggerAction: 'all',
value: 'clr', // <-- Desired initial value here.
valueField: 'val'
});