PDA

View Full Version : How to set default value for selectField form.



dmitryfisko
6 Jul 2012, 2:00 AM
Hi everyone.
I want to set default value for selectField form, for example
Chinese Simplified. Please tell me how to do it.


{ xtype: 'selectfield',
label: 'Field',
options: [
{
text: 'Auto-Detect',
value: ''
},
{
text: '-',
value: '-'
},
{
text: 'Arabic',
value: 'ar'
},
{
text: 'Bulgarian',
value: 'bg'
},
{
text: 'Catalan',
value: 'ca'
},
{
text: 'Chinese Simplified',
value: 'zh-CHS'
},
{
text: 'Chinese Traditional',
value: 'zh-CHT'
},
{
text: 'Czech',
value: 'cs'
},
{
text: 'Danish',
value: 'da'
},
{
text: 'Dutch',
value: 'nl'
},
{
text: 'English',
value: 'en'
},
{
text: 'Estonian',
value: 'et'
},
{
text: 'Finnish',
value: 'fi'
},
{
text: 'French',
value: 'fr'
},
{
text: 'German',
value: 'de'
},
{
text: 'Greek',
value: 'el'
},
{
text: 'Haitian Creole',
value: 'ht'
},
{
text: 'Hebrew',
value: 'he'
},
{
text: 'Hindi',
value: 'hi'
},
{
text: 'Hmong Daw',
value: 'mww'
},
{
text: 'Hungarian',
value: 'hu'
},
{
text: 'Indonesian',
value: 'id'
},
{
text: 'Italian',
value: 'it'
},
{
text: 'Japanese',
value: 'ja'
},
{
text: 'Korean',
value: 'ko'
},
{
text: 'Latvian',
value: 'lv'
},
{
text: 'Lithuanian',
value: 'lt'
},
{
text: 'Norwegian',
value: 'no'
},
{
text: 'Polish',
value: 'pl'
},
{
text: 'Portuguese',
value: 'pt'
},
{
text: 'Romanian',
value: 'ro'
},
{
text: 'Russian',
value: 'ru'
},
{
text: 'Slovak',
value: 'sk'
},
{
text: 'Slovenian',
value: 'sl'
},
{
text: 'Spanish',
value: 'es'
},
{
text: 'Swedish',
value: 'sv'
},
{
text: 'Thai',
value: 'th'
},
{
text: 'Turkish',
value: 'tr'
},
{
text: 'Ukrainian',
value: 'uk'
},
{
text: 'Vietnamese',
value: 'vi'
}
]
}

P.S. Sorry for my English.;)

sword-it
6 Jul 2012, 2:35 AM
Hello,
To set the default value in selectfield, you just need to provide 'value' config to the select field. Review the following code:




{
xtype: 'selectfield',
label: 'Field',
value: 'zh-CHS', // value of the language that you want to select
options: [
{
text: 'Auto-Detect',
value: ''
},
{
text: '-',
value: '-'
},
{
text: 'Chinese Simplified',
value: 'zh-CHS'
},
{
text: 'Chinese Traditional',
value: 'zh-CHT'
},
more items....
]
}

dmitryfisko
6 Jul 2012, 4:51 AM
Thank you very much.:)