Reputation: 1220
I'm working with ExtJS 4.1, I need to create a combo box containing a list of name and I'd like to set a specific pre-selected item in it, but I don't know how to do it. Here's the code to create my combo box:
{
xtype : 'combo',
fieldLabel : 'Pay Method',
triggerAction : 'all',
forceSelection: true,
store : 'S01I011001',
editable : false,
emptyText : 'Please Select',
name : 'payMethodId',
typeAhead : true,
queryMode : 'remote',
displayField : 'name',
valueField : 'id',
id : 'payMethod-t00700106',
listeners :{
'select': {
fn: function (combo, value) {
var value=combo.getValue();
if(value != null || value != ''){
if(value == '2' || value == '3'){
Ext.getCmp('return-t00700106').disable();
}else{
Ext.getCmp('return-t00700106').enable();
}
}
}
}
}
}
Upvotes: 1
Views: 1359
Reputation: 1220
I do it in this way , And activated store property autoLoad : true
{
xtype : 'combo',
fieldLabel : 'Pay Method',
triggerAction : 'all',
forceSelection: true,
store : 'S01I011001',
editable : false,
emptyText : 'Please Select',
name : 'payMethodId',
typeAhead : true,
queryMode : 'remote',
displayField : 'name',
valueField : 'id',
id : 'payMethod-t00700106',
listeners :{
boxready : function(){
this.setValue(this.getStore().getAt(0).get(this.valueField),true);
this.fireEvent('select',this);
}
}
}
Upvotes: 1
Reputation: 5712
Just use the 'value' property, and set it to the code value of the entry you want.
Upvotes: 2