PDA

View Full Version : help with combobox [half solved]



sj137
17 Jul 2008, 8:45 AM
Hi,

I have a combobox which is loaded from a local array of http character encoding values




var characterEncodingArray = [
['utf-8', 'utf-8'],
['iso-8859-1', 'iso-8859-1 (Western Europe)'],
['iso-8859-2', 'iso-8859-2 (Western and Central Europe)'],
['iso-8859-3', 'iso-8859-3 (Western Europe and South European)'],
['iso-8859-4', 'iso-8859-4 (Western Europe and Baltic countries)'],
['iso-8859-5', 'iso-8859-5 (Cyrillic alphabet)'],
['iso-8859-6', 'iso-8859-6 (Arabic)'],
['iso-8859-7', 'iso-8859-7 (Greek)'],
['iso-8859-8', 'iso-8859-8 (Hebrew)'],
['iso-8859-9', 'iso-8859-9 (Western Europe with Turkish)'],
['iso-8859-10', 'iso-8859-10 (Western Europe with Nordic languages)'],
['iso-8859-11', 'iso-8859-11 (Thai)'],
['iso-8859-13', 'iso-8859-13 (Baltics plus Polish)'],
['iso-8859-14', 'iso-8859-14 (Celtic languages)'],
['iso-8859-15', 'iso-8859-15 (ISO 8859-1 with Euro sign and other rationalisations)'],
['iso-8859-16', 'iso-8859-16 (Central European languages)'],
['windows-1250', 'windows-1250 (Central European languages that use Latin script)'],
['windows-1251', 'windows-1251 (Cyrillic alphabets)'],
['windows-1252', 'windows-1252 (Western languages)'],
['windows-1253', 'windows-1253 (Greek)'],
['windows-1254', 'windows-1254 (Turkish)'],
['windows-1255', 'windows-1255 (Hebrew)'],
['windows-1256', 'windows-1256 (Arabic)'],
['windows-1257', 'windows-1257 (Baltic languages)'],
['windows-1258', 'windows-1258 (Vietnamese)']
]



i want to display the 'name' in the drop-down list
but show the value in the field....

when i use getValue it gets whatever text is in the field... this is fine for me becuase i want to allow users to type in an encoding that i haven't listed if they want to.

however with my code below i can't achieve this result...



var encodingField = new Ext.form.ComboBox({
fieldLabel:"Encoding",
value:"type what you want here or select from the drop down list",
listWidth:'400',
store: new Ext.data.SimpleStore({
fields: ['value', 'name'],
data : characterEncodingArray
}),
displayField:'name',
typeAhead: true,
mode: 'local',
triggerAction: 'all'
});

var encodingValueToPOST = encodingField.getValue();


i've tried many combinations and search the forums but can't find out a simple way to do this...

please help

many thanks in advance

regards, SJ

sj137
18 Jul 2008, 12:23 AM
i got half way there....

NB i forgot to include the valueField parameter in the combobox config

valueField:'value',

so when i call encodingField.getValue()

i put an if...




if (encoding==''){encoding = encodingField.getRawValue();}



works fine for me now :D

i can do without only showing the value in the field... but if anyone knows, please post here for anyone else interested... including me ;)

ciao

S

sj137
21 Jul 2008, 7:49 AM
actually the code



if (encoding==''){encoding = encodingField.getRawValue();}


doesn't work...

instead i do:



var v = encodingField.getValue(), rv = encodingField.getRawValue();
var rec = encodingField.findRecord(encodingField.displayField,rv);
if (rec){ encoding = v; }else{encoding = rv;}



:)