PDA

View Full Version : Selecting an Element in a Combo



gnadirap
13 May 2010, 10:34 PM
Hi all

I have a country-combo in a form, which will loaded.

Now i want, that the User's country is selected, if he has choosen one before, else there's a message.
(All the other textfields are loaded perferctyl. Only the Combo is the "problem")

So. the Combo wasn't a problem so far:



{
fieldLabel: 'County',
name: 'county',
anchor: '95%'
},
{
name: 'country',
xtype:'combo',
fieldLabel: 'Country',
store: new Ext.data.Store({
url: connection,
baseParams: {
method: 'readCountries'
},
reader: new Ext.data.JsonReader({
fields: ['countries_id', 'countries_name','countries_iso_code_2','countries_iso_code_3'],
root: 'countries'
}),
autoLoad: true
}),
displayField:'countries_name',
valueField: 'countries_name',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select a Country...',
selectOnFocus:true,
anchor: '95%'
}

The server-Response for the Countries looks like this:


{'countries':[{"countries_id":"2","countries_name":"Albania","countries_iso_code_2":"AL","countries_iso_code_3":"ALB"},{"countries_id":"3","countries_name":"Algeria","countries_iso_code_2":"DZ","countries_iso_code_3":"DZA"}]}In the API i found these two params (select (http://intra-dev/ext/docs/source/Combo.html#method-Ext.form.ComboBox-select)( Number index, Boolean scrollIntoView ) & selectByValue (http://intra-dev/ext/docs/source/Combo.html#method-Ext.form.ComboBox-selectByValue)( String value, Boolean scrollIntoView ) ), through which (at least i think so) could select one of the lists element. but
that was not right..

Has someone an Example or a tipp for me, where the mistake, or the missunderstanding is?


Many Thanks for you Help.

Greetings

Gnadirap

Rothariger
14 May 2010, 2:48 AM
i guess the problem is this...

valueField: 'countries_name', -> valueField: 'countries_id'


greetings.