PDA

View Full Version : [Solved] Combobox init by value



mrsunshine
10 Jul 2009, 1:14 AM
Hi,

i have form which is filled by a binded record.

One value is displayed in a combobox. when i load the data in the form the combobox show me the right id (value). But i want that it select the name for the initial id.

the store is loaded but my selection dosent work.



..
{
fieldLabel:'test',
name: 'person_id',
xtype: 'combo',
store: new Ext.data.JsonStore({
autoLoad: true,
root: 'response.value.items',
fields: ['uid','name'],
url: urlCommandController,
baseParams: {
cmd: 'ListeLaden'
}
}),
displayField:'name',
valueField: 'uid',
forceSelection: true,
triggerAction: 'all',
emptyText:this.labelEmptyText,
selectOnFocus:true,
listeners:{
'afterrender': function(combo){
combo.store.on('load',function(){
combo.selectByValue(combo.getValue());

});
}
}


},
..

i am happy for any hint B)

Nils

Condor
10 Jul 2009, 1:19 AM
There are several possible solutions.

This one (http://extjs.com/forum/showthread.php?p=285246#post285246) is probably the easiest.

mrsunshine
10 Jul 2009, 1:41 AM
Perfect!! =D>